# Mister Download Manager for Android The Android app: MDM's own engine and interface (crates/app) in a GameActivity, laid out for a phone. `crates/android` is the native library the activity loads (`libmdm.so`); this folder is the Gradle project around it: the activity, what keeps downloads going in the background and their notifications (`Transfers.kt`), Android's keystore, alarms, clipboard, pickers and intents for the app (`Platform.kt`, `Picker.kt`), and the helper programs the APK carries. The app isn't in the releases yet. Its release builds (the Google Play edition's app bundle and the full edition's APKs, signed by the maintainer) are made as [RELEASING.md](RELEASING.md) says. ## Two editions The Gradle build has two flavors, and they differ in one place each: `editions` in `app/build.gradle.kts`, and `crates/app/src/edition.rs` for the app's code. | | `full` (GitHub, F-Droid) | `play` (Google Play) | |---|---|---| | Downloads from YouTube (youtube.com, youtu.be, music.youtube.com, m.youtube.com, youtube-nocookie.com, googlevideo.com) | yes | no: a shared, opened, copied or typed address there is refused with a short message, and a download from there in a list never starts | | Video pages (the APK's Python, ffmpeg and QuickJS) | yes, with the yt-dlp MDM installs and keeps up to date | yes, with the yt-dlp the APK carries (2026.10.26, pinned by its SHA-256), updated only with the app | | Updating itself or its helpers from outside its store | not yet (part 3 adds the full edition's updater) | never: no helper (yt-dlp, ffmpeg, gallery-dl, Node.js, Deno) is downloaded at all (`mdm_tools::freeze_helpers`), and Options has no Helpers | Everything else is the same: files, torrents, queues, the Scheduler, the phone layout. ## What you need - Rust with the Android targets: `rustup target add aarch64-linux-android` (and `armv7-linux-androideabi`, `x86_64-linux-android` for those ABIs), and `cargo install cargo-ndk --version 4.1.2 --locked` - JDK 21, and the Android SDK with NDK 28.2.13676358 (`sdkmanager "ndk;28.2.13676358"`); `ANDROID_HOME` (or `local.properties`' `sdk.dir`) set - [Gradle 8.14.3](https://gradle.org/releases/) (its SHA-256, `bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531`, is published at services.gradle.org beside it). The tree keeps no Gradle wrapper (no binaries in it); to make one for yourself: `gradle wrapper --gradle-version 8.14.3 --gradle-distribution-sha256-sum bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531` (git ignores it) - Nothing else: 7-Zip is built from its source with the NDK, Python, ffmpeg and QuickJS come from Maven Central at build time, and the Play edition's yt-dlp from its GitHub release (see [third_party/README.md](third_party/README.md)) - On Windows also the SDK's CMake (`sdkmanager "cmake;3.31.6"`, with Ninja: BoringSSL is built with them) and Git for Windows (its `sh` runs 7-Zip's makefile) `node tools/android/preflight.mjs` checks all of this and says what is missing; `--fix` downloads Gradle 8.14.3 (checked against the SHA-256 above) into `~/.gradle/mdm` and, on Linux and macOS, installs the NDK with `sdkmanager` (on Windows it says the `sdkmanager` command to type: it runs no batch file). ## Build ```sh cd android gradle assembleFullDebug # arm64-v8a, the phones most people have gradle assemblePlayDebug -Pmdm.abis=x86_64 # the Play edition, for the emulator gradle assembleFullDebug -Pmdm.abis=arm64-v8a,armeabi-v7a,x86_64 ``` Or from the repository's root, with the JDK, the SDK and Gradle found for you (the same on Windows, macOS and Linux): `node tools/android/build-android.mjs assembleFullDebug`. A release (both editions, every ABI, signed): `node tools/android/build-android.mjs release`, see [RELEASING.md](RELEASING.md). A release build without the maintainer's key is unsigned, never signed with the debug key. The APKs are `app/build/outputs/apk//debug/app--debug.apk`; install one with `adb install -r`. Other properties: `-Pmdm.cargoProfile=dev` (a quicker, larger `libmdm.so`; CI uses `android-ci`, the release's optimisation without its whole-program pass), `-Pmdm.skipCargo=true` (use the `libmdm.so` an earlier build left), `-Pmdm.sevenZipRar=false` (7-Zip without its RAR code), `-Pmdm.versionName=0.6.0-pre` (another versionName than the workspace's). Each edition's Rust build has its own target folder (`android-` under `CARGO_TARGET_DIR`, else under the repository's `target/`). The versionCode comes from git: the minutes from 2026-01-01 to the commit's time ([RELEASING.md](RELEASING.md#the-version)). CI builds both editions' debug APKs and runs them in an Android 14 emulator at a Pixel 6's density, then in an Android 16 one (`.github/workflows/android.yml`, `tools/android/smoke.sh`): the app starts, comes back when Android starts its screen again, downloads a file from the lab server while it is in the background and its notification moves, turns and takes a tablet's screen without restarting, finishes a queue of five downloads with the app in the background, each then in the Download folder under its own name, and the Play edition refuses YouTube addresses shared, opened and handed over and saves into a folder it makes and one another app made. Its screenshots, notifications and logs are the run's artifacts. A debug build takes three test extras for this, `com.misterdownloadmanager.android.TEST_DOWNLOAD` (an address downloaded at once), `...TEST_QUEUE` (addresses added to the main queue, which starts) and `...TEST_RELAUNCH` (the screen started again, as Android does for a change it doesn't hand over); a release build ignores them. ## Before a store submission A checklist for part 3, from Google Play's rules and the rejection patterns collected by [app-store-compliance](https://github.com/mjmirza/app-store-compliance) (its own licence, not GPL-compatible: linked, never copied). CI runs its release audit over this folder and the merged release manifests (`.github/workflows/android.yml`, the `android-store-compliance` artifact; advisory for now). `tools/android/verify-release.mjs` checks a release's own files for the target API, `REQUEST_INSTALL_PACKAGES`, an installer in the Play edition's code and locked orientation or resizing, on every release ([RELEASING.md](RELEASING.md)). - [ ] **Target API**: 36 (`targetSdk`), what Play asks of new apps and updates. - [ ] **No YouTube in `play`**: youtube.com, youtu.be, music.youtube.com, m.youtube.com, youtube-nocookie.com and googlevideo.com refused everywhere an address comes in, the video page look-up included (`crates/app/src/edition.rs`), and the listing says so plainly. - [ ] **No self-updating in `play`**: no updater, no `REQUEST_INSTALL_PACKAGES`, no executable code downloaded from outside Play: its yt-dlp is frozen in the APK, and every download of a helper fails (`mdm_tools::freeze_helpers`). A new yt-dlp comes with an app update (`ytDlpVersion` and `ytDlpSha256` in `app/build.gradle.kts`). - [ ] **Background work**: Android 14 and later keep downloads going with a user-initiated data transfer job (`RUN_USER_INITIATED_JOBS`); Android 13 and older with a `dataSync` foreground service, declared in the Play Console with a short video if asked. - [ ] **No `specialUse` foreground service, on purpose**: torrents *download* in the background as every download does (the transfer job, as long as one runs), and MDM keeps nothing running for *sharing* a completed torrent: once nothing downloads, the job ends and a torrent shares only while the app is in front (as on the desktop, where nothing holds the computer awake for sharing either). So no `specialUse` service, and nothing to declare for it. If one is added for sharing in the background, its `` must declare the `android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE` property, and the Play Console declaration would say: *"Mister Download Manager shares the BitTorrent downloads the user chose to keep sharing after they complete (seeding), as BitTorrent asks of every peer. The service runs only while such a torrent is being shared, shows an ongoing notification naming it with a Stop button, and ends when the user stops sharing or the share ratio or time limit the user set is reached. No other foreground service type fits: it is not a data sync, a media playback or a user-initiated transfer, and it lasts as long as the user keeps sharing."* - [ ] **Native libraries read-only** (Android 17, API 37, for what an app loads itself): `libmdm.so`, the helpers' programs and the Play edition's yt-dlp are installed by the system from the APK (`nativeLibraryDir`, read-only); what MDM unpacks itself (Python's standard library and its extension modules, ffmpeg's libraries) is made read-only once unpacked (`crates/tools/src/android.rs`). The APK keeps `extractNativeLibs` (`useLegacyPackaging`): the helper programs must be files to run. - [ ] **Large screens** (Play, from April 2027): no `screenOrientation` lock and no `resizeableActivity="false"` in the merged release manifests (CI checks both editions'); the activity takes rotation, folding and multi-window as configuration changes, and the emulator test turns it and gives it a tablet's screen without a restart. - [ ] **Data safety**: MDM collects and shares no data; the form must say what the app really does over the network (the downloads the user asks for, the debrid services the user signs in to, a crash report only when the user sends it). - [ ] **Listing**: no site names, no "download any video", the FDM-style line that YouTube isn't supported and that the user answers for what they download. ## What the app does - The phone's own layout (`crates/app/src/phone.rs`), in MDM's colours as the theme gives them (`palette.rs`'s `phone.*` roles and its green `go`: Windows 11's light window, MDM's navy board in dark, following the phone's light or dark setting): a bottom bar of four pages, Downloads, Browser (a placeholder until the phone's browser comes), Queues and Settings, the chosen one underlined in the accent. Downloads: a card of how the downloads go (their speed, **Pause all**, a meter of them together, how many run and are paused, how far, how long), the categories as chips with their counts, then rows for a finger with the file type's tile, the name and its Web or Torrent chip, a progress bar and the figures, each with its own Pause, Resume or folder button, and MDM's green **Add link** over the list's end. A tap opens a download (its page, or a finished one's file); a long press starts selection mode (check circles, "N selected", Select all, the picked downloads' menu, Resume / Stop / Delete at the bottom); the top bar searches the list (by file name) and its ⋮ has the rest of the commands (sorting first). Queues: the same with the queues as chips and Start / Stop queue. Settings: the settings a phone changes most, each opening where it is set - **Add a link** and **Download File Info** rise from the bottom as a sheet: the address with **Paste**, the file's card (its type, name and size; the pencil renames it), Save to (a tap picks another category), Download later and the green Start download; a link already copied goes straight to it. **Add link** without one opens the sheet with the address box (and **Use authorization**) first: a link pasted goes straight on, a typed one with OK or the keyboard's Go. While the keyboard is up, everything is laid out above it (the window keeps its size; egui's content rect leaves the keyboard out): the phone's sheets and pages, and the windows of the desktop's layout on a tablet or a phone turned - A download's page: a card of its figures, the classic segment bar of its connections over its progress bar, Pause (or the green Resume) and Cancel, its address (copied by a tap) and where it is saved, Properties / Open folder, its connections - Every window (Add URL, Download File Info, the progress window, Options, Add torrent...) as a page over the list, its title in a top bar whose × closes it, laid out for the phone's width with big buttons at the bottom (a few rarely used ones, such as Torrent settings, are drawn a little smaller to fit); pages slide in, menus rise from the bottom; **Back** closes the page, menu or selection in front, and on the list sends the app to the background - Downloads in `Download/MisterDownloadManager`, each type in its category's folder (made when a download first needs it, without asking; a folder elsewhere that isn't there is asked about); what a download needs to go on (its resume state) in the app's own storage, not beside the file (the phone's media database keeps a row for each file there and fought each save of it; one an earlier build left there is moved in at the start). Kept going in the background: on Android 14 and later by a user-initiated data transfer job (what Android gives a download the user started, with no time limit), on older ones by a data sync foreground service. Its notification says how they go ("2 downloading, 1.25 MB/sec") and has **Stop All**; each download has its own (a progress bar, its figures, **Stop**), and one that completes says so, with **Open**. The notifications are told once a second by a thread of their own in `libmdm.so` (`crates/app/src/android/notices.rs`), which reads the downloads themselves: they keep moving with the app in the background, when the interface draws nothing. **Stop** and **Stop All** stop the downloads at once there too. What the window does besides drawing (a queue's next download, a finished download's last steps, the Scheduler) goes on in the background too: a thread ticks the app while the activity is stopped (`android.rs`, `background`), and the job or service stays while a queue has downloads to start - Drawn at the display's own density (Android's `DisplayMetrics`), followed when it changes (the screen turned, another display), with the font size set in Android's settings applied on top of MDM's interface size - Links in: Share (text with links), a file's link opened with MDM (also a browser's "open the download with another app", such as Firefox for Android's), a magnet, a `.torrent` opened or shared; files out: **Open**, **Open with...**, **Share...** and **Open folder** through Android's apps - Sign-ins in Android's keystore, the Scheduler's exact alarms, the clipboard - The **...** buttons through Android's pickers: a folder on the phone's storage (or a card), a file to open copied into the app's cache (16 MB at most), a file to save in a folder picked there - Video downloads with the APK's Python, ffmpeg and QuickJS (and, in the Play edition, its own yt-dlp); 7z and RAR with its 7-Zip ## Not yet - Controls inside the pages keep the desktop's size (21 point fields and check boxes; a touch near one reaches it); only the pages' main buttons are a finger's size - A torrent shared after it completes isn't kept running in the background (no download runs then, so nothing keeps the app awake; Android would end it) - If Android ends the app, its downloads stop where they were and go on at its next start; resuming after the phone restarts isn't there (Android doesn't let an app open its screen by itself then). The same when Android closes the app's screen or starts it again for a change it doesn't hand over (the manifest takes all it can in place), or when a change taken in place comes before its window exists (eframe ends its loop for a window event then): one process runs the app's window once (winit makes one event loop per process), so the app saves, ends and starts again