Skip to content

The only downloader you need. 下载器的集大成者。

refactor: remove Qt Android

XiaoYouChR9c176477461e
diff --git a/android/.dockerignore b/android/.dockerignore
deleted file mode 100644
index cc92ebd4..00000000
--- a/android/.dockerignore
+++ /dev/null
@@ -1,7 +0,0 @@
-dist/
-*.apk
-__pycache__/
-*.pyc
-.buildozer/
-deployment/
-pysidedeploy.spec
diff --git a/android/.gitignore b/android/.gitignore
deleted file mode 100644
index d589840b..00000000
--- a/android/.gitignore
+++ /dev/null
@@ -1,10 +0,0 @@
-dist/
-deployment/
-*.apk
-.buildozer/
-
-pysidedeploy.spec
-buildozer.spec
-
-__pycache__/
-*.pyc
diff --git a/android/BUILD.md b/android/BUILD.md
deleted file mode 100644
index d3f4fd17..00000000
--- a/android/BUILD.md
+++ /dev/null
@@ -1,110 +0,0 @@
-# Android Build Notes
-
-Build and packaging knowledge for the PySide6 + python-for-android (p4a)
-Android target. Minimum supported version: Android 10 (API 29).
-
-## Docker CI
-
-The build runs in a custom Docker image with p4a, Android SDK/NDK, and Rust
-toolchain pre-installed. The Dockerfile lives in the CI workflow.
-
-### p4a template patches
-
-p4a copies template files (AndroidManifest, themes, resources) from
-`/opt/p4a/pythonforandroid/bootstraps/qt/build/` into the dist. **Patches to
-these templates are applied in the Docker image layer**, not in the
-buildozer cache volume — the cache gets overwritten on every dist assembly.
-
-Template patches are `sed` commands at the end of the Dockerfile, after the
-p4a install step. Three critical PythonActivity patches:
-
-**Back-key → moveTaskToBack**: without this patch, pressing back calls
-`onDestroy` + `killProcess`, killing downloads. The patch overrides
-`onKeyDown` to call `moveTaskToBack(false)` instead.
-
-**onActivityResult → super()**: without this patch, `QFileDialog` on Android
-deadlocks — `PythonActivity` never propagates the result to Qt.
-
-**onNewIntent → setIntent(intent)**: without this patch, re-entry via share
-intent returns the stale intent from the first launch (`sharedText()` sees
-old data).
-
-### Recipes
-
-Custom p4a recipes live in `android/recipes/`:
-
-- `jh2` — HTTP/2 with Rust extension (requires Rust toolchain in the image)
-- `wreq` — TLS fingerprint HTTP client (Rust + btls-sys)
-- `gd3ffmpeg` — pre-built FFmpeg binaries into `nativeLibraryDir`
-
-## APK size
-
-The base APK was reduced from ~159 MB to ~62 MB via:
-
-- Pruning unused Python stdlib modules (`android/patches/gd3_prune.py`)
-- Pre-built minimal FFmpeg instead of full build (~30 MB → ~6 MB)
-- N_m3u8DL-RE excluded from APK (runtime hot-install via linker64, see
- ADR 0005)
-
-## Signing
-
-Release keystore: `~/.gd3-android/release.jks`
-- Alias: `ghostdownloader`
-- First public release uses this keystore — Android binds the signing
- key permanently to the package name (see ADR 0006)
-
-CI secrets (GitHub Actions):
-- `ANDROID_KEYSTORE_BASE64` — base64-encoded `.jks`
-- `ANDROID_KEYSTORE_PASSWORD` — keystore + key password (same)
-- `ANDROID_KEY_ALIAS` — `ghostdownloader`
-
-## Runtime patches (`patches.py`)
-
-`app/view/mobile/patches.py` applies monkey-patches for PySide6-on-Android
-quirks. All patches are called from `app/view/mobile/__init__.py` during
-`setupAndroid()`.
-
-| Patch | What it fixes |
-|---|---|
-| `patchMenus` | RoundMenu reparented as child widget — second top-level window crashes EGL (ADR 0004) |
-| `patchIconRendering` | QSvgPlugin returns blank pixmaps → SvgIconEngine renders via QSvgRenderer |
-| `patchFileDialogs` | QFileDialog `content://` URIs → real filesystem paths via ContentResolver |
-| `patchDialogWidth` | MessageBoxBase limited to screen width on narrow devices |
-| `patchOptionCardLayout` | Horizontal setting/option cards reflowed to vertical |
-| `patchGroupTouch` | CollapsibleSettingCardGroup header tap toggles collapse (touch-friendly) |
-
-## Storage permission
-
-Android 11+ (API 30): `MANAGE_EXTERNAL_STORAGE` — broad file access, required
-for downloading to arbitrary folders. Android 10 and below:
-`WRITE_EXTERNAL_STORAGE`. `PermissionBanner` in `MobileMainWindow` blocks
-task creation until storage is granted.
-
-## StrictMode file URI
-
-Android 7+ (API 24) blocks `file://` URIs in intents by default.
-`_relaxFileUriPolicy()` in `app/platform/android.py` disables StrictMode's
-`FileUriExposedException` check so `Uri.fromFile` intents (open file, reveal
-folder) work.
-
-## Device debugging pitfalls
-
-### Screen-off pauses the Qt event loop
-
-When the screen turns off, Android pauses the activity. The Qt event loop
-stops processing — downloads freeze. The `KeepAlive` foreground service +
-`PARTIAL_WAKE_LOCK` keeps the CPU running, but the Qt event loop only
-resumes when the screen is on or the activity is in the foreground.
-
-### Insets double-inset
-
-Android system bars insets can be applied twice if both the activity theme
-and Qt handle them. Fix: let the activity theme handle status bar color,
-do not apply insets in Qt layout code.
-
-### Desktop preview via grab()
-
-For fast UI iteration without deploying to a real device, use
-`widget.grab().save("preview.png")` to render the widget off-screen on
-desktop. This works because `MobileMainWindow` is a plain `QWidget` with
-no Android-specific rendering.
diff --git a/android/Dockerfile b/android/Dockerfile
deleted file mode 100644
index ca2c8e67..00000000
--- a/android/Dockerfile
+++ /dev/null
@@ -1,178 +0,0 @@
-FROM python:3.11-bookworm
-
-ARG APT_MIRROR_HOST=deb.debian.org
-ARG PIP_INDEX=https://pypi.org/simple
-ARG QT_DL=https://download.qt.io/official_releases/QtForPython
-ARG RUSTUP_DIST_SERVER=https://static.rust-lang.org
-ARG RUSTUP_UPDATE_ROOT=https://static.rust-lang.org/rustup
-
-ENV DEBIAN_FRONTEND=noninteractive \
- PYSIDE_VERSION=6.10.2 \
- PIP_INDEX_URL=${PIP_INDEX} \
- RUSTUP_DIST_SERVER=${RUSTUP_DIST_SERVER} \
- RUSTUP_UPDATE_ROOT=${RUSTUP_UPDATE_ROOT}
-
-RUN sed -i "s|deb.debian.org|${APT_MIRROR_HOST}|g" /etc/apt/sources.list.d/debian.sources \
- && apt-get update && apt-get install -y --no-install-recommends \
- openjdk-17-jdk-headless \
- build-essential ccache git zip unzip wget curl file \
- autoconf automake libtool libtool-bin pkg-config \
- cmake \
- zlib1g-dev libffi-dev libssl-dev libncurses-dev \
- && rm -rf /var/lib/apt/lists/*
-
-ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
-
-ENV RUSTUP_HOME=/opt/rustup CARGO_HOME=/opt/cargo PATH="/opt/cargo/bin:${PATH}"
-RUN curl --proto '=https' --tlsv1.2 -sSf "${RUSTUP_UPDATE_ROOT}/dist/x86_64-unknown-linux-gnu/rustup-init" -o /tmp/rustup-init \
- && chmod +x /tmp/rustup-init \
- && /tmp/rustup-init -y --no-modify-path --default-toolchain stable \
- && rm /tmp/rustup-init \
- && rustup target add aarch64-linux-android \
- && chmod -R a+rX /opt/rustup /opt/cargo
-
-RUN pip install --no-cache-dir --timeout 300 --retries 10 \
- "PySide6==${PYSIDE_VERSION}" \
- "buildozer==1.5.0" \
- "cython==0.29.33" \
- jinja2 pkginfo tqdm "packaging==24.1"
-
-RUN DEPLOY_BZ=/usr/local/lib/python3.11/site-packages/PySide6/scripts/deploy_lib/android/buildozer.py \
- && DEPLOY_CFG=/usr/local/lib/python3.11/site-packages/PySide6/scripts/deploy_lib/android/android_config.py \
- && DEPLOY_UTIL=/usr/local/lib/python3.11/site-packages/PySide6/scripts/deploy_lib/deploy_util.py \
- && DEPLOY_AND=/usr/local/lib/python3.11/site-packages/PySide6/scripts/android_deploy.py \
- && sed -i 's|modls = self.get_value("qt", "modules")|modls = __import__("os").environ.get("GD3_QT_MODULES", "") or self.get_value("qt", "modules")|' "$DEPLOY_CFG" \
- && grep -q 'GD3_QT_MODULES' "$DEPLOY_CFG" && echo "[patch] GD3_QT_MODULES 注入 OK" \
- && sed -i 's|"requirements", "python3,shiboken6,PySide6"|"requirements", "python3==3.11.15,hostpython3==3.11.15,shiboken6,PySide6" + __import__("os").environ.get("GD3_EXTRA_REQ", "")|' "$DEPLOY_BZ" \
- && grep -q 'python3==3.11.15' "$DEPLOY_BZ" && echo "[patch] python pin OK" \
- && sed -i 's|f"{include_exts},qml,js"|f"{include_exts},qml,js,toml"|' "$DEPLOY_BZ" \
- && grep -q 'qml,js,toml' "$DEPLOY_BZ" && echo "[patch] include toml OK" \
- && sed -i 's|self.set_value("app", "android.permissions", permissions)|self.set_value("app", "android.permissions", (permissions + __import__("os").environ.get("GD3_EXTRA_PERM", "")).strip(", "))|' "$DEPLOY_BZ" \
- && grep -q 'GD3_EXTRA_PERM' "$DEPLOY_BZ" && echo "[patch] env-injectable req/perm OK" \
- && sed -i 's|self.set_value("app", "p4a.branch", "develop")|self.set_value("app", "p4a.branch", "develop"); _gp = __import__("os").environ.get("GD3_P4A_SOURCE", ""); _gp and self.set_value("app", "p4a.source_dir", _gp)|' "$DEPLOY_BZ" \
- && grep -q 'GD3_P4A_SOURCE' "$DEPLOY_BZ" && echo "[patch] p4a.source_dir injectable OK" \
- && sed -i 's|shutil.rmtree(buildozer_build)|None|' "$DEPLOY_UTIL" \
- && sed -i 's|shutil.move(buildozer_build_dir, config.generated_files_path)|None|' "$DEPLOY_AND" \
- && echo "[patch] incremental build OK"
-
-RUN mkdir -p /opt/qt-android-wheels && cd /opt/qt-android-wheels \
- && wget -q "${QT_DL}/pyside6/PySide6-6.10.2-6.10.2-cp311-cp311-android_aarch64.whl" \
- && wget -q "${QT_DL}/shiboken6/shiboken6-6.10.2-6.10.2-cp311-cp311-android_aarch64.whl" \
- && ls -la /opt/qt-android-wheels
-
-ARG P4A_GIT_URL=https://github.com/kivy/python-for-android.git
-ENV GD3_P4A_SOURCE=/opt/p4a
-COPY patches/qt_pyjniusjni.c /opt/qt_pyjniusjni.c
-COPY gradle-init.gradle /opt/gradle-init.gradle
-
-COPY recipes/ /opt/gd3-recipes/
-COPY patches/gd3_prune.py /opt/gd3_prune.py
-RUN git clone --depth 1 -b develop "${P4A_GIT_URL}" /opt/p4a \
- && QTSRC=/opt/p4a/pythonforandroid/bootstraps/qt/build/jni/application/src \
- && cp /opt/qt_pyjniusjni.c "$QTSRC/pyjniusjni.c" \
- && sed -i 's|LOCAL_SRC_FILES := start.c|LOCAL_SRC_FILES := start.c pyjniusjni.c|' "$QTSRC/Android.mk" \
- && grep -q 'start.c pyjniusjni.c' "$QTSRC/Android.mk" && echo "[patch] qt bootstrap pyjniusjni OK" \
- && cp -r /opt/gd3-recipes/* /opt/p4a/pythonforandroid/recipes/ \
- && ls -d /opt/p4a/pythonforandroid/recipes/jh2 && echo "[patch] gd3 recipes 装入 OK" \
- && COMMONBUILD=/opt/p4a/pythonforandroid/bootstraps/common/build/build.py \
- && sed -i 's#^\( *\)with open(join(res_dir, .mipmap-anydpi-v26/icon.xml.), .w.) as fd:#\1ensure_dir(join(res_dir, "mipmap-anydpi-v26"))\n&#' "$COMMONBUILD" \
- && grep -q 'ensure_dir(join(res_dir, "mipmap-anydpi-v26"))' "$COMMONBUILD" && echo "[patch] p4a adaptive icon mkdir fix OK" \
- && cp /opt/gd3_prune.py /opt/p4a/pythonforandroid/gd3_prune.py \
- && sed -i 's| self.distribute_libs(arch, \[self.ctx.get_libs_dir(arch.arch)\])| from pythonforandroid import gd3_prune as _gp; _gp.pruneQt(self.ctx.get_libs_dir(arch.arch), join(self.ctx.get_python_install_dir(arch.arch), "PySide6"), info)\n self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])|' /opt/p4a/pythonforandroid/bootstraps/qt/__init__.py \
- && grep -q 'gd3_prune' /opt/p4a/pythonforandroid/bootstraps/qt/__init__.py && echo "[patch] gd3 Qt 瘦身钩子注入 OK" \
- && QTPA=/opt/p4a/pythonforandroid/bootstraps/qt/build/src/main/java/org/kivy/android/PythonActivity.java \
- && sed -i '/protected void onActivityResult(int requestCode, int resultCode, Intent intent) {/a\ super.onActivityResult(requestCode, resultCode, intent);' "$QTPA" \
- && grep -q 'super.onActivityResult' "$QTPA" && echo "[patch] qt PythonActivity super.onActivityResult OK" \
- && sed -i '/public boolean onKeyDown(int keyCode, KeyEvent event) {/a\ if (keyCode == KeyEvent.KEYCODE_BACK) { moveTaskToBack(true); return true; }' "$QTPA" \
- && grep -q 'moveTaskToBack' "$QTPA" && echo "[patch] qt PythonActivity 返回键退后台 OK" \
- && sed -i '/protected void onNewIntent(Intent intent) {/a\ setIntent(intent);' "$QTPA" \
- && grep -q 'setIntent(intent)' "$QTPA" && echo "[patch] qt PythonActivity onNewIntent setIntent(热启分享 getIntent 生效) OK" \
- && QTSTR=/opt/p4a/pythonforandroid/bootstraps/qt/build/templates/strings.tmpl.xml \
- && sed -i '/<item name="android:windowNoTitle">true<\/item>/a\ <item name="android:windowBackground">@drawable/gd3_splash</item>\n <item name="android:windowSplashScreenBackground">@color/gd3_splash_bg</item>' "$QTSTR" \
- && sed -i '/<resources>/a\ <color name="gd3_splash_bg">#f3f3f3</color>' "$QTSTR" \
- && grep -q 'windowSplashScreenBackground' "$QTSTR" && echo "[patch] qt native SplashScreen(API31 windowSplashScreen) OK" \
- && chmod -R a+rX /opt/p4a
-
-# Minimal LGPL FFmpeg from our own build repo (~3MB tarball with ffmpeg+ffprobe),
-# replacing hzw1199's full build (~30MB). Pinned to a tag for reproducible APKs;
-# bump the tag to update. See https://github.com/XiaoYouChR/Ghost-Downloader-FFmpeg
-ARG FFMPEG_TARBALL=https://github.com/XiaoYouChR/Ghost-Downloader-FFmpeg/releases/download/n8.1.2-gd1/ffmpeg-android-arm64.tar.gz
-ARG NM3U8_URL=https://github.com/nilaoda/N_m3u8DL-RE/releases/download/v0.6.0-beta/N_m3u8DL-RE_v0.6.0-beta_android-bionic-arm64_20260629.tar.gz
-RUN mkdir -p /opt/gd3-ffmpeg && cd /opt/gd3-ffmpeg \
- && wget -q "${FFMPEG_TARBALL}" -O /tmp/ffmpeg.tar.gz \
- && tar -xzf /tmp/ffmpeg.tar.gz -C /tmp \
- && cp /tmp/ffmpeg /opt/gd3-ffmpeg/libffmpeg.so \
- && cp /tmp/ffprobe /opt/gd3-ffmpeg/libffprobe.so \
- && rm -f /tmp/ffmpeg.tar.gz /tmp/ffmpeg /tmp/ffprobe \
- && wget -q "${NM3U8_URL}" -O /tmp/nm3u8.tar.gz \
- && tar -xzf /tmp/nm3u8.tar.gz -C /tmp \
- && cp /tmp/N_m3u8DL-RE /opt/gd3-ffmpeg/libnm3u8dlre.so \
- && rm -f /tmp/nm3u8.tar.gz /tmp/N_m3u8DL-RE \
- && chmod a+rx libffmpeg.so libffprobe.so libnm3u8dlre.so \
- && ls -la /opt/gd3-ffmpeg \
- && file libffmpeg.so | grep -q "ARM aarch64" && echo "[ffmpeg] minimal arm64 预置 OK" \
- && file libnm3u8dlre.so | grep -q "ARM aarch64" && echo "[nm3u8] bionic arm64 预置 OK"
-
-# QuickJS-NG for yt-dlp YouTube JS challenge solving.
-# Static musl binary from releases works on Android (issue #1512).
-ARG QJS_VERSION=v0.15.1
-RUN mkdir -p /opt/gd3-qjs && cd /opt/gd3-qjs \
- && wget -q "https://github.com/quickjs-ng/quickjs/releases/download/${QJS_VERSION}/qjs-linux-aarch64" -O libqjs.so \
- && chmod a+rx libqjs.so \
- && file libqjs.so | grep -q "ARM aarch64" && echo "[qjs] static arm64 预置 OK"
-
-RUN DEPLOY_BASECFG=/usr/local/lib/python3.11/site-packages/PySide6/scripts/deploy_lib/config.py \
- && DEPLOY_BZ=/usr/local/lib/python3.11/site-packages/PySide6/scripts/deploy_lib/android/buildozer.py \
- && sed -i 's|config_icon = self.get_value("app", "icon")|config_icon = __import__("os").environ.get("GD3_ICON", "") or self.get_value("app", "icon")|' "$DEPLOY_BASECFG" \
- && grep -q 'GD3_ICON' "$DEPLOY_BASECFG" && echo "[patch] GD3_ICON 注入 OK" \
- && sed -i 's| self.set_value("app", "icon.filename", pysidedeploy_config.icon)|&\n self.set_value("app", "icon.adaptive_foreground.filename", __import__("os").environ.get("GD3_ICON_FG", ""), raise_warning=False)\n self.set_value("app", "icon.adaptive_background.filename", __import__("os").environ.get("GD3_ICON_BG", ""), raise_warning=False)\n self.set_value("app", "android.add_resources", __import__("os").environ.get("GD3_RES", ""), raise_warning=False)|' "$DEPLOY_BZ" \
- && grep -q 'GD3_ICON_FG' "$DEPLOY_BZ" && grep -q 'add_resources' "$DEPLOY_BZ" && echo "[patch] GD3 adaptive icon + add_resources 注入 OK" \
- && sed -i 's|"title", pysidedeploy_config.title)|"title", __import__("os").environ.get("GD3_APP_TITLE", "") or pysidedeploy_config.title)|' "$DEPLOY_BZ" \
- && sed -i 's|"package.name", pysidedeploy_config.title)|"package.name", __import__("os").environ.get("GD3_PKG_NAME", "") or pysidedeploy_config.title)|' "$DEPLOY_BZ" \
- && sed -i 's|f"org.{pysidedeploy_config.title}")|(__import__("os").environ.get("GD3_PKG_DOMAIN", "") or f"org.{pysidedeploy_config.title}"))|' "$DEPLOY_BZ" \
- && grep -q 'GD3_APP_TITLE' "$DEPLOY_BZ" && grep -q 'GD3_PKG_NAME' "$DEPLOY_BZ" && grep -q 'GD3_PKG_DOMAIN' "$DEPLOY_BZ" && echo "[patch] GD3 包名/显示名注入 OK"
-
-ARG GD3_GRADLE_CN=0
-RUN useradd -m -u 1000 builder \
- && mkdir -p /home/builder/.pyside6_android_deploy /home/builder/.buildozer /home/builder/.gradle /home/builder/stage \
- && if [ "$GD3_GRADLE_CN" = "1" ]; then cp /opt/gradle-init.gradle /home/builder/.gradle/init.gradle; fi \
- && chown -R builder:builder /home/builder \
- && chown builder:builder /opt/p4a
-
-RUN QTSTR=/opt/p4a/pythonforandroid/bootstraps/qt/build/templates/strings.tmpl.xml \
- && sed -i '/<item name="android:windowSplashScreenBackground">@color\/gd3_splash_bg<\/item>/a\ <item name="android:windowDrawsSystemBarBackgrounds">true</item>\n <item name="android:statusBarColor">@color/gd3_splash_bg</item>\n <item name="android:windowLightStatusBar">@bool/gd3_light_status_bar</item>' "$QTSTR" \
- && sed -i '/<color name="gd3_splash_bg">#f3f3f3<\/color>/a\ <bool name="gd3_light_status_bar">true</bool>' "$QTSTR" \
- && grep -q 'statusBarColor' "$QTSTR" \
- && chown builder:builder "$QTSTR" \
- && echo "[patch] qt 状态栏沉浸 statusBarColor+windowLightStatusBar OK"
-
-# minapi=28: Qt 6.10 库硬要求 ≥28(Android 9)。app 存储授权按 SDK 分支(≥30 All Files / <30 WRITE + manifest
-# requestLegacyExternalStorage), 故下限贴齐 Qt 的 Android 9; minapi 与 ndk_api 一并设, 否则声明 SDK 与 .so 编译 API 错位。
-RUN DEPLOY_BZ=/usr/local/lib/python3.11/site-packages/PySide6/scripts/deploy_lib/android/buildozer.py \
- && sed -i '/self.set_value("app", "title",/a\ self.set_value("app", "version", __import__("os").environ.get("GD3_VERSION", "") or "0.1")\n self.set_value("app", "android.accept_sdk_license", "True")\n self.set_value("buildozer", "log_level", "1")\n self.set_value("app", "android.minapi", __import__("os").environ.get("GD3_MINAPI", "") or "28")\n self.set_value("app", "android.ndk_api", __import__("os").environ.get("GD3_MINAPI", "") or "28")' "$DEPLOY_BZ" \
- && grep -q 'GD3_VERSION' "$DEPLOY_BZ" && grep -q 'accept_sdk_license' "$DEPLOY_BZ" && grep -q 'log_level' "$DEPLOY_BZ" && grep -q 'android.minapi' "$DEPLOY_BZ" && echo "[patch] GD3_VERSION + accept_sdk_license + log_level + minapi/ndk_api=28 注入 OK"
-
-COPY java/org/ghostdownloader/KeepAliveService.java /opt/p4a/pythonforandroid/bootstraps/common/build/src/main/java/org/ghostdownloader/KeepAliveService.java
-RUN QTMAN=/opt/p4a/pythonforandroid/bootstraps/qt/build/templates/AndroidManifest.tmpl.xml \
- && sed -i '/<\/application>/i\ <service android:name="org.ghostdownloader.KeepAliveService" android:exported="false" android:foregroundServiceType="dataSync" />' "$QTMAN" \
- && sed -i '0,/<\/activity>/{s## <meta-data android:name="android.app.background_running" android:value="true" />\n </activity>#}' "$QTMAN" \
- && sed -i '0,/<\/activity>/{s## <intent-filter>\n <action android:name="android.intent.action.SEND" />\n <category android:name="android.intent.category.DEFAULT" />\n <data android:mimeType="text/plain" />\n </intent-filter>\n </activity>#}' "$QTMAN" \
- && sed -i '0,/<\/activity>/{s## <intent-filter>\n <action android:name="android.intent.action.SEND" />\n <category android:name="android.intent.category.DEFAULT" />\n <data android:mimeType="application/x-bittorrent" />\n <data android:mimeType="audio/x-mpegurl" />\n <data android:mimeType="audio/mpegurl" />\n <data android:mimeType="application/vnd.apple.mpegurl" />\n <data android:mimeType="application/dash+xml" />\n </intent-filter>\n </activity>#}' "$QTMAN" \
- && sed -i '0,/<\/activity>/{s## <intent-filter>\n <action android:name="android.intent.action.SEND_MULTIPLE" />\n <category android:name="android.intent.category.DEFAULT" />\n <data android:mimeType="application/x-bittorrent" />\n <data android:mimeType="audio/x-mpegurl" />\n <data android:mimeType="audio/mpegurl" />\n <data android:mimeType="application/vnd.apple.mpegurl" />\n <data android:mimeType="application/dash+xml" />\n </intent-filter>\n </activity>#}' "$QTMAN" \
- && sed -i 's/<application /<application android:requestLegacyExternalStorage="true" /' "$QTMAN" \
- && grep -q 'KeepAliveService' "$QTMAN" \
- && grep -q 'background_running' "$QTMAN" \
- && grep -q 'requestLegacyExternalStorage' "$QTMAN" \
- && grep -q 'android.intent.action.SEND' "$QTMAN" \
- && grep -q 'android.intent.action.SEND_MULTIPLE' "$QTMAN" \
- && grep -q 'application/x-bittorrent' "$QTMAN" \
- && chown -R builder:builder /opt/p4a/pythonforandroid/bootstraps/common/build/src/main/java/org/ghostdownloader \
- && echo "[patch] KeepAliveService + background_running + requestLegacyExternalStorage + SEND/SEND_MULTIPLE intent-filter(文本+文件分享入口) 注入 OK"
-
-# 隔离的新版 cmake 专供 wreq 的 btls-sys/BoringSSL(系统 cmake 3.25 在 NDK toolchain 下 FindThreads 会炸)
-RUN python3 -m venv /opt/cmake4 \
- && for i in 1 2 3 4 5; do /opt/cmake4/bin/pip install --no-cache-dir --timeout 300 --retries 10 "cmake>=4.0" && break || sleep 5; done \
- && /opt/cmake4/bin/cmake --version
-
-USER builder
-WORKDIR /work
diff --git a/android/build_apk.sh b/android/build_apk.sh
deleted file mode 100644
index 6f333b80..00000000
--- a/android/build_apk.sh
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-WHEEL_DIR=/opt/qt-android-wheels
-ANDROID_DIR=/work
-REPO=/repo
-STAGE=/home/builder/stage
-
-mkdir -p "$STAGE"
-rm -rf "$STAGE/app" "$STAGE/features"
-cp -a "$REPO/app" "$STAGE/app"
-cp -a "$REPO/features" "$STAGE/features"
-cp -a "$ANDROID_DIR/main.py" "$STAGE/main.py"
-rm -rf "$STAGE/features/bittorrent_pack"
-rm -rf "$STAGE/features/ed2k_pack"
-rm -rf "$STAGE/features/jack_yao"
-find "$STAGE/app" "$STAGE/features" -name "__pycache__" -type d -prune -exec rm -rf {} +
-
-cd "$STAGE"
-
-rm -f "$STAGE/pysidedeploy.spec" "$STAGE/buildozer.spec"
-
-find "$STAGE" -name "*.apk" -delete
-BUILD_MARKER="$STAGE/.build_marker"
-touch "$BUILD_MARKER"
-
-export GD3_EXTRA_REQ="${GD3_EXTRA_REQ:-,pyjnius,wreq,charset-normalizer,idna,certifi,PySide6-Fluent-Widgets,PySideSix-Frameless-Window,darkdetect,loguru,qrcode,pypng,m3u8,mpegdash,aioftp,gd3ffmpeg,gd3qjs}"
-export GD3_EXTRA_PERM="${GD3_EXTRA_PERM:-,MANAGE_EXTERNAL_STORAGE,POST_NOTIFICATIONS,FOREGROUND_SERVICE,FOREGROUND_SERVICE_DATA_SYNC,REQUEST_IGNORE_BATTERY_OPTIMIZATIONS,WAKE_LOCK}"
-
-export GD3_ICON="${GD3_ICON:-$REPO/app/assets/logo.png}"
-
-export GD3_ICON_FG="${GD3_ICON_FG:-$ANDROID_DIR/res/icon_foreground.png}"
-export GD3_ICON_BG="${GD3_ICON_BG:-$ANDROID_DIR/res/icon_background.png}"
-
-export GD3_RES="${GD3_RES:-$ANDROID_DIR/res/values-night/colors.xml:values-night/colors.xml,$ANDROID_DIR/res/splash_logo.png:drawable-nodpi/gd3_splash_logo.png,$ANDROID_DIR/res/drawable/gd3_splash.xml:drawable/gd3_splash.xml}"
-
-export GD3_APP_TITLE="${GD3_APP_TITLE:-Ghost Downloader}"
-export GD3_PKG_NAME="${GD3_PKG_NAME:-ghostdownloader}"
-export GD3_PKG_DOMAIN="${GD3_PKG_DOMAIN:-io.github.xiaoyouchr}"
-
-RAW_VERSION=$(grep -oP '^VERSION = "\K[^"]+' "$REPO/app/config/constants.py")
-export GD3_VERSION="${GD3_VERSION:-${RAW_VERSION%%-*}}"
-
-export GD3_QT_MODULES="${GD3_QT_MODULES:-Core,Gui,Widgets,Network,Svg,SvgWidgets,WebSockets,Xml}"
-echo "[build] STAGE=$STAGE"
-echo "[build] applicationId=$GD3_PKG_DOMAIN.$GD3_PKG_NAME label=$GD3_APP_TITLE"
-echo "[build] adaptive icon fg=$GD3_ICON_FG bg=$GD3_ICON_BG"
-echo "[build] GD3_EXTRA_REQ=$GD3_EXTRA_REQ GD3_EXTRA_PERM=$GD3_EXTRA_PERM"
-echo "[build] GD3_QT_MODULES=$GD3_QT_MODULES"
-
-PYSIDE_WHL=$(ls "$WHEEL_DIR"/PySide6-*android_aarch64.whl)
-SHIBOKEN_WHL=$(ls "$WHEEL_DIR"/shiboken6-*android_aarch64.whl)
-echo "[build] PySide6 wheel: $PYSIDE_WHL"
-echo "[build] shiboken wheel: $SHIBOKEN_WHL"
-
-pyside6-android-deploy -f -v \
- --name GhostDownloaderProbe \
- --wheel-pyside "$PYSIDE_WHL" \
- --wheel-shiboken "$SHIBOKEN_WHL"
-
-mkdir -p "$ANDROID_DIR/dist"
-
-FRESH_APK=$(find "$STAGE" -name "*.apk" -newer "$BUILD_MARKER" -printf "%T@ %p\n" 2>/dev/null | sort -rn | head -1 | cut -d' ' -f2-)
-rm -f "$BUILD_MARKER"
-if [ -z "$FRESH_APK" ]; then
- echo "[build] 错误:未找到本次新生成的 APK!" >&2
- exit 1
-fi
-cp -v "$FRESH_APK" "$ANDROID_DIR/dist/"
-
-if [ -n "${GD3_KEYSTORE:-}" ]; then
- BUILD_TOOLS=$(ls -d "$HOME"/.buildozer/android/platform/android-sdk/build-tools/*/ 2>/dev/null | sort -V | tail -1)
- if [ -z "$BUILD_TOOLS" ]; then echo "[build] 错误:找不到 build-tools(apksigner/zipalign)" >&2; exit 1; fi
- DEBUG_APK="$ANDROID_DIR/dist/$(basename "$FRESH_APK")"
- RELEASE_APK="${DEBUG_APK%-debug.apk}-release.apk"
- "${BUILD_TOOLS}zipalign" -f -p 4 "$DEBUG_APK" "$RELEASE_APK"
- "${BUILD_TOOLS}apksigner" sign --ks "$GD3_KEYSTORE" \
- --ks-pass "pass:$GD3_KEYSTORE_PASS" \
- --ks-key-alias "$GD3_KEY_ALIAS" \
- --key-pass "pass:${GD3_KEY_PASS:-$GD3_KEYSTORE_PASS}" \
- "$RELEASE_APK"
- "${BUILD_TOOLS}apksigner" verify --print-certs "$RELEASE_APK" >/dev/null && echo "[build] 已签名 release: $RELEASE_APK"
- rm -f "$DEBUG_APK"
-fi
-
-echo "[build] 产物(本次新构建):"
-ls -la "$ANDROID_DIR/dist"
diff --git a/android/gradle-init.gradle b/android/gradle-init.gradle
deleted file mode 100644
index 8da29cac..00000000
--- a/android/gradle-init.gradle
+++ /dev/null
@@ -1,17 +0,0 @@
-allprojects {
- buildscript {
- repositories {
- maven { url 'https://maven.aliyun.com/repository/google' }
- maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
- maven { url 'https://maven.aliyun.com/repository/central' }
- google()
- mavenCentral()
- }
- }
- repositories {
- maven { url 'https://maven.aliyun.com/repository/google' }
- maven { url 'https://maven.aliyun.com/repository/central' }
- google()
- mavenCentral()
- }
-}
diff --git a/android/java/org/ghostdownloader/KeepAliveService.java b/android/java/org/ghostdownloader/KeepAliveService.java
deleted file mode 100644
index 5939cc84..00000000
--- a/android/java/org/ghostdownloader/KeepAliveService.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.ghostdownloader;
-
-import android.app.Notification;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.app.Service;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ServiceInfo;
-import android.os.Build;
-import android.os.IBinder;
-
-public class KeepAliveService extends Service {
- private static final String CHANNEL_ID = "gd3_keepalive";
- private static final int NOTIFICATION_ID = 0x47443301;
-
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- String text = (intent != null) ? intent.getStringExtra("text") : null;
- if (text == null) {
- text = "正在后台运行";
- }
- Notification notification = buildNotification(text);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
- startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC);
- } else {
- startForeground(NOTIFICATION_ID, notification);
- }
-
- return START_NOT_STICKY;
- }
-
- private Notification buildNotification(String text) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- NotificationChannel channel = new NotificationChannel(
- CHANNEL_ID, "后台任务", NotificationManager.IMPORTANCE_LOW);
- manager.createNotificationChannel(channel);
- }
-
- Notification.Builder builder = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
- ? new Notification.Builder(this, CHANNEL_ID)
- : new Notification.Builder(this);
-
- Intent launch = getPackageManager().getLaunchIntentForPackage(getPackageName());
- if (launch != null) {
- int pendingFlags = PendingIntent.FLAG_UPDATE_CURRENT;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- pendingFlags |= PendingIntent.FLAG_IMMUTABLE;
- }
- builder.setContentIntent(PendingIntent.getActivity(this, 0, launch, pendingFlags));
- }
-
- return builder
- .setSmallIcon(getApplicationInfo().icon)
- .setContentTitle("Ghost Downloader")
- .setContentText(text)
- .setOngoing(true)
- .build();
- }
-}
diff --git a/android/main.py b/android/main.py
deleted file mode 100644
index fa3ced68..00000000
--- a/android/main.py
+++ /dev/null
@@ -1,165 +0,0 @@
-import os
-import sys
-import traceback
-from pathlib import Path
-
-from loguru import logger
-
-from app.config.paths import APP_DATA_DIR
-
-Path(APP_DATA_DIR).mkdir(parents=True, exist_ok=True)
-logger.add(f"{APP_DATA_DIR}/GhostDownloader.log", rotation="512 KB", retention=5)
-
-
-def _exceptionHook(exceptionType, value, tb):
- info = (exceptionType, value, tb)
- logger.opt(exception=info).error("Unhandled application exception")
-
-
-sys.excepthook = _exceptionHook
-
-
-def setupEnvironment():
- import certifi
- os.environ.setdefault("SSL_CERT_FILE", certifi.where())
-
- import warnings
- from qfluentwidgets import qconfig
- from app.config.cfg import cfg
- from app.config.constants import VERSION
- from app.platform.android import nativeLibraryDir
-
- from app.view.qfw_patch import patchFluentLabelThemeChanged, patchStackedWidgetAnimation
- from app.view.components.labels import IconBodyLabel
- patchFluentLabelThemeChanged()
- patchStackedWidgetAnimation()
- qconfig.themeChanged.connect(IconBodyLabel.clearCache)
- qconfig.load(f"{APP_DATA_DIR}/UserConfig.json", cfg)
- logger.info("Ghost Downloader v{} (Android) launched", VERSION)
-
- if cfg.dpiScale.value != 0:
- os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0"
- os.environ["QT_SCALE_FACTOR"] = str(cfg.dpiScale.value)
-
- from app.config.cfg import proxy
- logger.info("proxy: {}", proxy())
-
- warnings.warn = logger.warning
- nativeLibraryDir()
-
-
-def startApp(application):
- from app.config.cfg import cfg
- from app.platform.android_keepalive import keepAlive, REASON_DOWNLOAD, REASON_BROWSER, requestIgnoreBatteryOptimizations
- from app.platform.android_notification import (
- notifyBrowserPaired, notifyBrowserTaskAdded, notifyDiskSpaceInsufficient,
- notifyTaskCompleted,
- )
- from app.signal_bus import signalBus
- from app.startup import loadEngine, createServices, loadPacks, startEngine, bindNotifications, checkUpdateAtStartup, stopEngine
- from app.view.mobile.device import setupTouchScrolling
- from app.view.mobile.window import MobileMainWindow
-
- def exceptionHook(exceptionType, value, tb):
- _exceptionHook(exceptionType, value, tb)
- message = "".join(traceback.format_exception(exceptionType, value, tb)).rstrip()
- signalBus.exceptionCaught.emit(message)
-
- sys.excepthook = exceptionHook
-
- coroutineRunner, categoryService, speedMeter = loadEngine(application)
- featureService, taskService, browserService, aria2RpcServer, updateService, runtimeStatusService = createServices(
- coroutineRunner, categoryService, speedMeter,
- )
- loadPacks(featureService, coroutineRunner, speedMeter)
-
- mainWindow = MobileMainWindow(taskService, featureService, browserService, categoryService, speedMeter, coroutineRunner, updateService)
- mainWindow.show()
- setupTouchScrolling(mainWindow)
-
- taskService.taskStarted.connect(lambda _: keepAlive.holdFor(REASON_DOWNLOAD))
- taskService.tasksAllCompleted.connect(lambda: keepAlive.release(REASON_DOWNLOAD))
- speedMeter.speedChanged.connect(keepAlive.setSpeed)
-
- startEngine(taskService, speedMeter, featureService, coroutineRunner)
-
- signalBus.exceptionCaught.connect(mainWindow.alertException)
-
- requestIgnoreBatteryOptimizations()
-
- bindNotifications(taskService, notifyTaskCompleted, notifyDiskSpaceInsufficient)
-
- def onBrowserTaskDraftRequested(tasks):
- for task in tasks:
- taskService.add(task)
- notifyBrowserTaskAdded(tasks)
-
- def onBrowserPairRequested(request):
- browserService.approvePair(request["session"], request["requestId"])
- notifyBrowserPaired(request.get("peerAddress", ""))
-
- browserService.taskDraftRequested.connect(onBrowserTaskDraftRequested)
- browserService.pairRequested.connect(onBrowserPairRequested)
-
- aria2RpcServer.taskDraftRequested.connect(onBrowserTaskDraftRequested)
- if cfg.isAria2RpcEnabled.value:
- aria2RpcServer.start()
- cfg.isAria2RpcEnabled.valueChanged.connect(aria2RpcServer.setEnabled)
-
- def onAria2PortChanged(_port):
- if cfg.isAria2RpcEnabled.value:
- aria2RpcServer.stop()
- aria2RpcServer.start()
-
- cfg.aria2RpcPort.valueChanged.connect(onAria2PortChanged)
-
- def onBrowserExtensionToggled(enabled):
- if enabled:
- keepAlive.holdFor(REASON_BROWSER)
- else:
- keepAlive.release(REASON_BROWSER)
- browserService.setEnabled(enabled)
-
- cfg.isBrowserExtensionEnabled.valueChanged.connect(onBrowserExtensionToggled)
-
- def onBrowserPortChanged(_port):
- if cfg.isBrowserExtensionEnabled.value:
- browserService.stop()
- browserService.start()
-
- cfg.browserExtensionPort.valueChanged.connect(onBrowserPortChanged)
- if cfg.isBrowserExtensionEnabled.value:
- keepAlive.holdFor(REASON_BROWSER)
- browserService.start()
-
- from app.services.update_service import UpdateState
- def onUpdateChanged(info):
- if info.targetId == "app" and info.state == UpdateState.AVAILABLE:
- mainWindow._onUpdateAvailable(info)
- elif info.targetId != "app" and info.state == UpdateState.AVAILABLE:
- updateService.download(info.targetId)
- elif info.targetId != "app" and info.state == UpdateState.READY:
- from qfluentwidgets import InfoBar, InfoBarPosition
- InfoBar.success(
- mainWindow.tr("功能包更新"),
- mainWindow.tr("{0} 将在下次启动时生效").format(info.label),
- duration=5000,
- position=InfoBarPosition.BOTTOM_RIGHT,
- parent=mainWindow,
- )
- updateService.changed.connect(onUpdateChanged)
- checkUpdateAtStartup(updateService)
-
- application.aboutToQuit.connect(lambda: stopEngine(taskService, browserService, aria2RpcServer, featureService, coroutineRunner, speedMeter, updateService))
-
-
-if __name__ == "__main__":
- from app.platform.application import SingletonApplication
-
- setupEnvironment()
- app = SingletonApplication(sys.argv, "gd3")
- # setupAndroid 须在 QApplication 之后: setupFont 的 QFontDatabase 需要 QGuiApplication
- from app.view.mobile import setupAndroid
- setupAndroid()
- startApp(app)
- sys.exit(app.exec())
diff --git a/android/make_launch_assets.py b/android/make_launch_assets.py
deleted file mode 100644
index 19b41111..00000000
--- a/android/make_launch_assets.py
+++ /dev/null
@@ -1,70 +0,0 @@
-from pathlib import Path
-
-from PySide6.QtCore import QPointF, QRect, Qt
-from PySide6.QtGui import QColor, QImage, QLinearGradient, QPainter
-
-REPO = Path(__file__).resolve().parent.parent
-LOGO = REPO / "app" / "assets" / "logo.png"
-GHOST = REPO / "app" / "assets" / "logo_withoutBackground.png"
-OUT = REPO / "android" / "res"
-
-GHOST_SCALE = 0.40
-
-GRADIENT_TOP = QColor(201, 198, 226)
-GRADIENT_BOTTOM = QColor(174, 205, 245)
-
-def contentRect(image: QImage) -> QRect:
- width, height = image.width(), image.height()
- minX, minY, maxX, maxY = width, height, 0, 0
- for y in range(height):
- for x in range(width):
- if (image.pixel(x, y) >> 24) & 0xFF > 128:
- minX, minY = min(minX, x), min(minY, y)
- maxX, maxY = max(maxX, x), max(maxY, y)
- return QRect(minX, minY, maxX - minX + 1, maxY - minY + 1)
-
-def saveForegroundIcon() -> None:
- ghost = QImage(str(GHOST)).convertToFormat(QImage.Format.Format_ARGB32)
- size = ghost.width()
- cropped = ghost.copy(contentRect(ghost))
- target = int(size * GHOST_SCALE)
- scaled = cropped.scaled(
- target, target,
- Qt.AspectRatioMode.KeepAspectRatio,
- Qt.TransformationMode.SmoothTransformation,
- )
- canvas = QImage(size, size, QImage.Format.Format_ARGB32)
- canvas.fill(Qt.GlobalColor.transparent)
- painter = QPainter(canvas)
- painter.drawImage((size - scaled.width()) // 2, (size - scaled.height()) // 2, scaled)
- painter.end()
- canvas.save(str(OUT / "icon_foreground.png"))
-
-def saveBackgroundIcon() -> None:
- size = QImage(str(GHOST)).width()
- background = QImage(size, size, QImage.Format.Format_RGB888)
- gradient = QLinearGradient(QPointF(0, 0), QPointF(0, size))
- gradient.setColorAt(0.0, GRADIENT_TOP)
- gradient.setColorAt(1.0, GRADIENT_BOTTOM)
- painter = QPainter(background)
- painter.fillRect(background.rect(), gradient)
- painter.end()
- background.save(str(OUT / "icon_background.png"))
-
-def saveSplashLogo() -> None:
- # 开屏(windowBackground)居中徽标。用 logo.png 而非裸幽灵: 裸幽灵是白的、浅色开屏底上隐形;
- # logo.png 自带圆角渐变底深浅都可见, 圆角外透明处由 layer-list 底色层透出(随 values-night 切)。
- logo = QImage(str(LOGO)).convertToFormat(QImage.Format.Format_ARGB32)
- scaled = logo.scaled(
- 512, 512,
- Qt.AspectRatioMode.KeepAspectRatio,
- Qt.TransformationMode.SmoothTransformation,
- )
- scaled.save(str(OUT / "splash_logo.png"))
-
-if __name__ == "__main__":
- OUT.mkdir(parents=True, exist_ok=True)
- saveForegroundIcon()
- saveBackgroundIcon()
- saveSplashLogo()
- print(f"已生成: {', '.join(p.name for p in sorted(OUT.glob('*')))}")
diff --git a/android/patches/gd3_prune.py b/android/patches/gd3_prune.py
deleted file mode 100644
index edd0ec6c..00000000
--- a/android/patches/gd3_prune.py
+++ /dev/null
@@ -1,76 +0,0 @@
-import os
-import re
-import shutil
-from os.path import isdir, join
-
-KEEP = {
- "Core", "Core5Compat", "Concurrent", "DBus", "Gui", "Widgets",
- "Network", "WebSockets", "Xml", "Svg", "SvgWidgets",
- "OpenGL", "OpenGLWidgets", "PrintSupport", "Sql",
-}
-
-FFMPEG_LIBS = ("libavcodec", "libavformat", "libavutil", "libavdevice",
- "libavfilter", "libswscale", "libswresample", "libQt6FFmpegStub")
-
-MODULE_RE = (
- re.compile(r"^libQt6([A-Za-z0-9]+)_arm64-v8a\.so$"),
- re.compile(r"^Qt([A-Za-z0-9]+)\.abi3\.so$"),
- re.compile(r"^Qt6([A-Za-z0-9]+)_arm64-v8a-android-dependencies\.xml$"),
-)
-
-UNUSED_PLUGINS = {
- "sceneparsers", "assetimporters", "renderers", "geometryloaders",
- "qmltooling", "scenegraph", "webview", "designer", "position", "sensors",
- "multimedia",
-}
-
-
-def pruneDir(d):
- if not isdir(d):
- return 0
- freed = 0
- for name in list(os.listdir(d)):
- mod = None
- for rx in MODULE_RE:
- m = rx.match(name)
- if m:
- mod = m.group(1)
- break
- if (mod is not None and mod not in KEEP) or name.startswith(FFMPEG_LIBS):
- p = join(d, name)
- try:
- freed += os.path.getsize(p)
- os.remove(p)
- except OSError:
- pass
- return freed
-
-
-def removeDir(d):
- if not isdir(d):
- return 0
- total = 0
- for root, _, files in os.walk(d):
- for f in files:
- try:
- total += os.path.getsize(join(root, f))
- except OSError:
- pass
- shutil.rmtree(d, ignore_errors=True)
- return total
-
-
-def pruneQt(libs, pyside, log):
- freed = 0
- freed += pruneDir(libs)
- freed += pruneDir(join(pyside, "Qt", "lib"))
- freed += pruneDir(pyside)
-
- freed += removeDir(join(pyside, "Qt", "qml"))
- freed += removeDir(join(pyside, "Qt", "translations"))
-
- for plugin in UNUSED_PLUGINS:
- freed += removeDir(join(pyside, "Qt", "plugins", plugin))
- log("[gd3-prune] 裁掉未用 Qt 模块/QML/translations,释放 ~{} MB(keep={} 个模块)".format(
- freed // 1024 // 1024, len(KEEP)))
- return freed
diff --git a/android/patches/qt_pyjniusjni.c b/android/patches/qt_pyjniusjni.c
deleted file mode 100644
index 5e82342e..00000000
--- a/android/patches/qt_pyjniusjni.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <jni.h>
-#include <dlfcn.h>
-#include <android/log.h>
-
-#define LOG_TAG "gd3_pyjniusjni"
-#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
-
-static JavaVM *g_vm = NULL;
-
-JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
-{
- g_vm = vm;
- return JNI_VERSION_1_6;
-}
-
-static JavaVM *resolve_vm(void)
-{
- if (g_vm) {
- return g_vm;
- }
-
- typedef jint (*get_vms_fn)(JavaVM **, jsize, jsize *);
- get_vms_fn get_vms = (get_vms_fn)dlsym(RTLD_DEFAULT, "JNI_GetCreatedJavaVMs");
- if (!get_vms) {
- void *handle = dlopen("libnativehelper.so", RTLD_NOW);
- if (handle) {
- get_vms = (get_vms_fn)dlsym(handle, "JNI_GetCreatedJavaVMs");
- }
- }
- if (get_vms) {
- JavaVM *vm = NULL;
- jsize count = 0;
- if (get_vms(&vm, 1, &count) == JNI_OK && count > 0) {
- g_vm = vm;
- return vm;
- }
- }
- LOGE("failed to resolve JavaVM");
- return NULL;
-}
-
-void *WebView_AndroidGetJNIEnv(void)
-{
- JavaVM *vm = resolve_vm();
- if (!vm) {
- return NULL;
- }
- JNIEnv *env = NULL;
- (*vm)->AttachCurrentThread(vm, &env, NULL);
- return env;
-}
diff --git a/android/preview.py b/android/preview.py
deleted file mode 100644
index 93e54df5..00000000
--- a/android/preview.py
+++ /dev/null
@@ -1,47 +0,0 @@
-import sys
-from pathlib import Path
-
-sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
-
-import app.platform.android as _android
-_android.nativeLibraryDir = lambda: ""
-_android.isStorageGranted = lambda: True
-_android.requestStoragePermission = lambda: None
-_android.sharedText = lambda: None
-_android.clearShare = lambda: None
-_android.isSystemDark = lambda: False
-
-import app.platform.android_notification as _notif
-_notif.isNotificationEnabled = lambda: True
-_notif.requestNotificationPermission = lambda: None
-
-
-if __name__ == "__main__":
- from main import setupEnvironment
- from app.platform.application import SingletonApplication
- from app.startup import loadEngine, loadPacks, startEngine, stopEngine
-
- setupEnvironment()
- app = SingletonApplication(sys.argv, "gd3-mobile-preview")
-
- from app.view.mobile import setupAndroid
- setupAndroid()
-
- from app.startup import createServices, loadPacks, startEngine, stopEngine
-
- coroutineRunner, categoryService, speedMeter = loadEngine(app)
- featureService, taskService, browserService, aria2RpcServer, updateService, runtimeStatusService = createServices(
- coroutineRunner, categoryService, speedMeter,
- )
- loadPacks(featureService, coroutineRunner, speedMeter)
-
- from app.view.mobile.window import MobileMainWindow
- from app.view.mobile.device import setupTouchScrolling
- window = MobileMainWindow(taskService, featureService, browserService, categoryService, speedMeter, coroutineRunner)
- window.resize(400, 800)
- window.show()
- setupTouchScrolling(window)
-
- startEngine(taskService, speedMeter, featureService, coroutineRunner)
- app.aboutToQuit.connect(lambda: stopEngine(taskService, browserService, aria2RpcServer, featureService, coroutineRunner, speedMeter))
- sys.exit(app.exec())
diff --git a/android/recipes/gd3ffmpeg/__init__.py b/android/recipes/gd3ffmpeg/__init__.py
deleted file mode 100644
index 52c5ebaf..00000000
--- a/android/recipes/gd3ffmpeg/__init__.py
+++ /dev/null
@@ -1,33 +0,0 @@
-from os.path import join
-
-from pythonforandroid.recipe import Recipe
-from pythonforandroid.logger import info, error
-
-class Gd3ffmpegRecipe(Recipe):
- version = "8.1.1"
- url = None
-
- PREBUILT_DIR = "/opt/gd3-ffmpeg"
- BINARIES = ("libffmpeg.so", "libffprobe.so", "libnm3u8dlre.so")
-
- def should_build(self, arch):
- return True
-
- def prepare_build_dir(self, arch):
- from pythonforandroid.util import ensure_dir
- ensure_dir(self.get_build_dir(arch))
-
- def unpack(self, arch):
- pass
-
- def build_arch(self, arch):
- from os.path import exists
- libs = [join(self.PREBUILT_DIR, b) for b in self.BINARIES]
- for lib in libs:
- if not exists(lib):
- error(f"[gd3ffmpeg] 预置二进制缺失: {lib}(检查 Dockerfile 下载步骤)")
- raise FileNotFoundError(lib)
- info(f"[gd3ffmpeg] install_libs 预编 ffmpeg/ffprobe -> lib/{arch.arch}/")
- self.install_libs(arch, *libs)
-
-recipe = Gd3ffmpegRecipe()
diff --git a/android/recipes/gd3qjs/__init__.py b/android/recipes/gd3qjs/__init__.py
deleted file mode 100644
index b6a9e78b..00000000
--- a/android/recipes/gd3qjs/__init__.py
+++ /dev/null
@@ -1,34 +0,0 @@
-from os.path import join
-
-from pythonforandroid.recipe import Recipe
-from pythonforandroid.logger import info, error
-
-
-class Gd3qjsRecipe(Recipe):
- version = "0.15.1"
- url = None
-
- PREBUILT_DIR = "/opt/gd3-qjs"
- BINARIES = ("libqjs.so",)
-
- def should_build(self, arch):
- return True
-
- def prepare_build_dir(self, arch):
- from pythonforandroid.util import ensure_dir
- ensure_dir(self.get_build_dir(arch))
-
- def unpack(self, arch):
- pass
-
- def build_arch(self, arch):
- from os.path import exists
- libs = [join(self.PREBUILT_DIR, b) for b in self.BINARIES]
- for lib in libs:
- if not exists(lib):
- error(f"[gd3qjs] 预置二进制缺失: {lib}(检查 Dockerfile 编译步骤)")
- raise FileNotFoundError(lib)
- info(f"[gd3qjs] install_libs 预编 qjs -> lib/{arch.arch}/")
- self.install_libs(arch, *libs)
-
-recipe = Gd3qjsRecipe()
diff --git a/android/recipes/jh2/__init__.py b/android/recipes/jh2/__init__.py
deleted file mode 100644
index 4ed1a571..00000000
--- a/android/recipes/jh2/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from pythonforandroid.recipe import RustCompiledComponentsRecipe
-
-class Jh2Recipe(RustCompiledComponentsRecipe):
- version = "5.0.13"
- url = "https://github.com/jawah/h2/archive/refs/tags/v{version}.tar.gz"
- site_packages_name = "jh2"
-
-recipe = Jh2Recipe()
diff --git a/android/recipes/wreq/__init__.py b/android/recipes/wreq/__init__.py
deleted file mode 100644
index 45c952e6..00000000
--- a/android/recipes/wreq/__init__.py
+++ /dev/null
@@ -1,39 +0,0 @@
-import os
-from glob import glob
-from os.path import join
-
-from pythonforandroid.recipe import RustCompiledComponentsRecipe
-
-
-class WreqRecipe(RustCompiledComponentsRecipe):
- version = "0.12.0"
- url = "https://files.pythonhosted.org/packages/source/w/wreq/wreq-{version}.tar.gz"
- site_packages_name = "wreq"
-
- def get_recipe_env(self, arch, **kwargs):
- env = super().get_recipe_env(arch, **kwargs)
- llvm = self.ctx.ndk.llvm_prebuilt_dir
- clang_include = glob(join(llvm, "lib", "clang", "*", "include"))[0]
-
- # maturin 隔离子进程不继承镜像 ENV, 显式喂 rustup 并强制 toolchain(绕开"无默认")
- env["RUSTUP_HOME"] = os.environ.get("RUSTUP_HOME", "/opt/rustup")
- env["RUSTUP_TOOLCHAIN"] = "stable"
- # 镜像的 /opt/cargo 是 root 只读, builder 下载 crate 写不进; 用可写的 home cargo
- env["CARGO_HOME"] = join(os.path.expanduser("~"), ".cargo")
- # android 目标过不了 auditwheel(非 manylinux), 跳过(同上游 CI)
- env["MATURIN_PEP517_ARGS"] = "--skip-auditwheel"
- # btls-sys 0.5.6 编 BoringSSL 走 NDK 的 cmake toolchain, 需要这个指路
- env["ANDROID_NDK_HOME"] = self.ctx.ndk_dir
- # 镜像自带 cmake 3.25 在 NDK toolchain 下 FindThreads 会失败, 用隔离的 cmake>=4
- env["CMAKE"] = "/opt/cmake4/bin/cmake"
- # bindgen 给 BoringSSL 生成绑定, libclang 在 NDK 的 musl/lib 下
- env["LIBCLANG_PATH"] = join(llvm, "musl", "lib")
- env["BINDGEN_EXTRA_CLANG_ARGS"] = (
- f"--target=aarch64-linux-android{self.ctx.ndk_api} "
- f"--sysroot={self.ctx.ndk.sysroot} -isystem {clang_include}"
- )
- env["PATH"] = join(llvm, "bin") + ":" + env["PATH"]
- return env
-
-
-recipe = WreqRecipe()
diff --git a/android/res/drawable/gd3_splash.xml b/android/res/drawable/gd3_splash.xml
deleted file mode 100644
index 11acb9a6..00000000
--- a/android/res/drawable/gd3_splash.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 冷启动开屏: Qt 未起时由系统绘制, 铺到 app 首帧。底色 @color/gd3_splash_bg 有 values-night 覆盖, 随深浅切。 -->
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@color/gd3_splash_bg" />
- <item>
- <bitmap android:src="@drawable/gd3_splash_logo" android:gravity="center" />
- </item>
-</layer-list>
diff --git a/android/res/icon_background.png b/android/res/icon_background.png
deleted file mode 100644
index 4377bef8..00000000
Binary files a/android/res/icon_background.png and /dev/null differ
diff --git a/android/res/icon_foreground.png b/android/res/icon_foreground.png
deleted file mode 100644
index 7c845765..00000000
Binary files a/android/res/icon_foreground.png and /dev/null differ
diff --git a/android/res/splash_logo.png b/android/res/splash_logo.png
deleted file mode 100644
index 399ad27d..00000000
Binary files a/android/res/splash_logo.png and /dev/null differ
diff --git a/android/res/values-night/colors.xml b/android/res/values-night/colors.xml
deleted file mode 100644
index b0d6e75b..00000000
--- a/android/res/values-night/colors.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <color name="gd3_splash_bg">#202020</color>
-
- <bool name="gd3_light_status_bar">false</bool>
-</resources>
diff --git a/android/run_build.sh b/android/run_build.sh
deleted file mode 100644
index 22b1f172..00000000
--- a/android/run_build.sh
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-IMAGE=gd3-android-builder
-HERE="$(cd "$(dirname "$0")" && pwd)"
-REPO_ROOT="$(cd "$HERE/.." && pwd)"
-
-BUILD_ARGS=()
-if [[ "${GD3_CN_MIRROR:-0}" == "1" ]]; then
- echo "[run] 启用国内镜像源构建镜像"
- BUILD_ARGS=(
- --build-arg "APT_MIRROR_HOST=mirrors.tuna.tsinghua.edu.cn"
- --build-arg "PIP_INDEX=https://mirrors.bfsu.edu.cn/pypi/web/simple"
- --build-arg "QT_DL=https://mirrors.ustc.edu.cn/qtproject/official_releases/QtForPython"
- --build-arg "RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static"
- --build-arg "RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup"
- --build-arg "P4A_GIT_URL=https://gitee.com/mirrors/python-for-android.git"
- --build-arg "FFMPEG_TARBALL=https://gh-proxy.com/https://github.com/XiaoYouChR/Ghost-Downloader-FFmpeg/releases/download/n8.1.2-gd1/ffmpeg-android-arm64.tar.gz"
- --build-arg "NM3U8_URL=https://gh-proxy.com/https://github.com/nilaoda/N_m3u8DL-RE/releases/download/v0.6.0-beta/N_m3u8DL-RE_v0.6.0-beta_android-bionic-arm64_20260629.tar.gz"
- --build-arg "GD3_GRADLE_CN=1"
- )
-fi
-
-RUN_PROXY=()
-NET_HOST=()
-BUILD_PROXY=()
-if [[ -n "${HTTP_PROXY:-}" ]]; then
- echo "[run] 检测到 HTTP_PROXY=$HTTP_PROXY,透传给镜像构建 + APK 构建容器"
- RUN_PROXY=(-e "HTTP_PROXY=$HTTP_PROXY" -e "HTTPS_PROXY=${HTTPS_PROXY:-$HTTP_PROXY}"
- -e "http_proxy=$HTTP_PROXY" -e "https_proxy=${HTTPS_PROXY:-$HTTP_PROXY}"
- -e "NO_PROXY=localhost,127.0.0.1,::1")
- NET_HOST=(--network=host)
- # docker build 经 --network=host 用宿主 clash; BuildKit 自动把这些代理 arg 注入每个 RUN
- BUILD_PROXY=(--network=host
- --build-arg "HTTP_PROXY=$HTTP_PROXY" --build-arg "HTTPS_PROXY=${HTTPS_PROXY:-$HTTP_PROXY}"
- --build-arg "http_proxy=$HTTP_PROXY" --build-arg "https_proxy=${HTTPS_PROXY:-$HTTP_PROXY}"
- --build-arg "NO_PROXY=localhost,127.0.0.1,::1")
-fi
-
-SIGN_ARGS=()
-if [[ -n "${GD3_KEYSTORE:-}" ]]; then
- echo "[run] 检测到 GD3_KEYSTORE,将签名为 release APK"
- SIGN_ARGS=(-v "$GD3_KEYSTORE":/tmp/release.jks:ro
- -e "GD3_KEYSTORE=/tmp/release.jks"
- -e "GD3_KEYSTORE_PASS=${GD3_KEYSTORE_PASS:-}"
- -e "GD3_KEY_ALIAS=${GD3_KEY_ALIAS:-}"
- -e "GD3_KEY_PASS=${GD3_KEY_PASS:-}")
-fi
-
-echo "[run] 构建镜像 $IMAGE ..."
-docker build "${BUILD_ARGS[@]}" "${BUILD_PROXY[@]}" -t "$IMAGE" "$HERE"
-
-mkdir -p "$HERE/dist" && chmod 777 "$HERE/dist"
-
-echo "[run] 容器内构建 APK ..."
-docker run --rm "${NET_HOST[@]}" "${RUN_PROXY[@]}" "${SIGN_ARGS[@]}" \
- -v "$HERE":/work \
- -v "$REPO_ROOT":/repo:ro \
- -v gd3-app-stage:/home/builder/stage \
- -v gd3-pyside-android-cache:/home/builder/.pyside6_android_deploy \
- -v gd3-buildozer-cache:/home/builder/.buildozer \
- -v gd3-gradle-cache:/home/builder/.gradle \
- "$IMAGE" bash /work/build_apk.sh
-
-echo "[run] 完成。装机命令:"
-echo " adb install -r $HERE/dist/*.apk"