Skip to content

Modernize and fix for Android 15-17 (AGP 9, SDK 37, JNI scanner) - #107

Merged
IvanVolosyuk merged 1 commit into
IvanVolosyuk:masterfrom
bartman081523:pr-upstream
Nov 21, 2026
Merged

IvanVolosyuk merged 1 commit into
IvanVolosyuk:masterfrom
bartman081523:pr-upstream

Conversation

@bartman081523

Copy link
Copy Markdown

Hi Ivan,

this branch contains the work I did to keep DiskUsage usable on current Android,
rebased on your master (including the modernize-build PR) and also dropping the
dead IPackageStatsObserver stubs.

F-Droid: I filed an update for the existing F-Droid entry
(https://gitlab.com/fdroid/fdroiddata/-/merge_requests/58153) built from my fork.
It was closed with "We don't accept forks without original dev's approval."
If you merge this PR — or just reply here that the fork may be used as the
F-Droid source — the F-Droid entry can be updated either way. No pressure: if
you'd rather keep maintenance yourself, this PR is the whole story and I'm happy
to send smaller follow-ups instead of maintaining a fork.

Why

On Android 14–17 several things are broken:

What changed

Build — AGP 9.5.1, Gradle 9.9.1, built-in Kotlin, JDK 17, version catalog,
configuration cache, R8 + resource shrinking, compileSdk/targetSdk 37,
minSdk 24, NDK r28c with 16 KB page-size compatible libraries, release builds
unsigned unless a keystore is configured (F-Droid/reproducible-build friendly).

Scanner — the tree walker is called through JNI instead of exec, streams
records while walking (live progress, flat memory), has a 5 s kill timeout, does
not follow symlinks, and falls back to the Java scanner on any failure.

Storage / app data — volume discovery through
StorageManager.getStorageVolumes(), autoselect when a single volume exists;
app list from PackageManager instead of UsageStatsManager;
StorageStatsManager with graceful degradation when usage access is missing;
null-safe getExternalCacheDir()/getExternalFilesDir()/obb/media dirs; delete
confirmation lists content off the UI thread.

UI — edge-to-edge insets, DayNight theme, real toolbars, adaptive/round/
monochrome launcher icons, TV banner, per-app locales, "Internal storage" label,
occupied percentage, double tap to open, folder opening via the
externalstorage documents URI (with copy-path fallback), a permissions screen
for the two special app-ops, and back navigation through
OnBackPressedDispatcher.

Infra — unit tests, a CI workflow (build, test, lint, 16 KB page-size check),
fastlane metadata, version.properties + scripts/bump-version.sh, CHANGELOG,
CONTRIBUTING and docs (including a triage of the open issues).

Version codes are major * 10000 + minor * 100 + patch (5.0.2 → 50002) with
tags v<version>, which continues your 5.0-alpha1 (5001).

Testing

./gradlew assembleDebug assembleRelease testDebugUnitTest lintDebug passes.
Runtime smoke tests on an Android 16 device (Xiaomi) and an API 35 emulator:
first-run permission flow, scan progress, folder/app opening, back navigation,
delete confirmation and the permissions dialog.

Notes

  • If the PR is too large for a review, I can split it into build, scanner and
    UI/scanner-follow-ups.
  • Translations are untouched; fastlane/metadata only adds store metadata.

Build
* AGP 9.5.1, Gradle 9.9.1, built-in Kotlin, JDK 17, version catalog,
  configuration cache, R8 with resource shrinking.
* compileSdk/targetSdk 37 (Android 17), minSdk 24, NDK r28c, 16 KB page-size
  native libraries.
* Release builds are unsigned unless a keystore is configured (F-Droid and
  reproducible-build friendly).

Scanner
* libscan.so was executed as a child process. The ELF is a shared object
  without a startup routine, so it segfaults on modern Android and the app
  always fell back to the Java scanner. It is now called through JNI,
  streaming records while walking (progress works, memory stays flat).
* IOException/RuntimeException fall back to the Java scanner instead of
  crashing; a stuck helper is killed after 5 s.

Storage and app data
* Volume discovery through StorageManager.getStorageVolumes(): internal
  storage, SD cards and USB drives, with autoselect for a single volume.
* App list from PackageManager instead of UsageStatsManager; cache sizes are
  reported again; degrades to APK sizes without usage access.
* Null-safe handling of getExternalCacheDir()/getExternalFilesDir()/obb/media
  dirs (NPE after clearing app data).
* Delete confirmation lists content off the UI thread.

UI
* Edge-to-edge insets, DayNight theme, real toolbars, adaptive/round/monochrome
  launcher icons, TV banner, per-app locales, internal-storage label.
* Opening files/folders: content URIs with read grants; folders go through the
  externalstorage documents URI so a real file manager is offered; copy-path
  dialog as fallback.
* Back navigation handled via OnBackPressedDispatcher (predictive back); a
  single-volume device leaves the app and keeps its task.
* Double tap opens entries, used/free space shows the occupied percentage,
  permissions screen for the two special app-ops.

Infra
* Unit tests, lint, CI workflow, fastlane metadata, version.properties with
  scripts/bump-version.sh, CHANGELOG/CONTRIBUTING/docs, issue triage.
* Drops the dead IPackageStatsObserver AIDL and AppStats stubs.

Tested with assembleDebug/assembleRelease/testDebugUnitTest/lintDebug and on an
Android 16 device plus an API 35 emulator (first-run permissions, scan, folder
opening, back navigation).
@cheack

cheack commented Nov 19, 2026

Copy link
Copy Markdown

Hey @bartman081523
I dropped by this repo to fork it and start working on some modernization, and spotted your PR. I installed the APK from your repository - it looks pretty good and everything works. Since this project seems abandoned, if I were you, I'd just continue developing your own fork. I actually have a couple of ideas for improvements as well.

@bartman081523

Copy link
Copy Markdown
Author

@IvanVolosyuk one thing I still need from you, sorry for the noise: F-Droid would like a one-line statement for the existing app entry (com.google.android.diskusage, last published version 5.0-alpha1 from 2024). Is this repository abandoned, and may a maintained fork be used as the F-Droid source? Either answer works: if you prefer to keep the source here, merging this PR unblocks it just as well. Thanks!

bartman081523 pushed a commit to bartman081523/diskusage that referenced this pull request Nov 19, 2026
Records the facts F-Droid reviewers ask for: last release 5.0-alpha1
(2023-12-07), no tags since, README points users at a maintained fork, and the
work was offered upstream in IvanVolosyuk#107 where the original
author was asked for a statement.
@IvanVolosyuk
IvanVolosyuk merged commit f56a1c5 into IvanVolosyuk:master Nov 21, 2026
@IvanVolosyuk

Copy link
Copy Markdown
Owner

Thanks for doing the changes. I'm no longer interested in android development, but if somebody can takeover maintenance - I have no objections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants