Repository navigation
Modernize and fix for Android 15-17 (AGP 9, SDK 37, JNI scanner) - #107
Conversation
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).
|
Hey @bartman081523 |
|
@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! |
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.
|
Thanks for doing the changes. I'm no longer interested in android development, but if somebody can takeover maintenance - I have no objections. |
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 thedead
IPackageStatsObserverstubs.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:
libscan.sois exec'd as a child process. It is a shared object without astartup routine, so it segfaults and the app always falls back to the slow Java
scanner — that is the
Error: no more datacrash in java.lang.RuntimeException: Error: no more data #16/java.lang.RuntimeException: Error: no more data #33.getExternalFilesDirs()are listed, so internalstorage, SD cards and USB drives disappear on several ROMs
(Disk Usage does not display internal memory for scan #83, support USB storage #78, After Lollipop 5.0.2 update: Removable SD not selectable #31, Unable to scan through the phone's External sdcard. #28, External SD card not scanned #27, folder /storage/extSdCard (2. SD-Card) #21).
UsageStatsManager, so most apps are missing(cannot read apps #98, Cannot scan App Storage #34) and cache sizes are wrong (App Cache sizes not showing on OxygenOS 15 #105).
ends in "No viewer found" (Regression: no viewer found #86, Openening a video is done in a "strange" mode #88, 5.0-alpha1 - double clic on a file doesn't have any effect #89).
nullgetExternalCacheDir()crashes the whole scan after clearing app data.What changed
Build — AGP 9.5.1, Gradle 9.9.1, built-in Kotlin, JDK 17, version catalog,
configuration cache, R8 + resource shrinking,
compileSdk/targetSdk37,minSdk24, NDK r28c with 16 KB page-size compatible libraries, release buildsunsigned unless a keystore is configured (F-Droid/reproducible-build friendly).
Scanner — the tree walker is called through JNI instead of
exec, streamsrecords 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
PackageManagerinstead ofUsageStatsManager;StorageStatsManagerwith graceful degradation when usage access is missing;null-safe
getExternalCacheDir()/getExternalFilesDir()/obb/media dirs; deleteconfirmation 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
externalstoragedocuments URI (with copy-path fallback), a permissions screenfor 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) withtags
v<version>, which continues your5.0-alpha1(5001).Testing
./gradlew assembleDebug assembleRelease testDebugUnitTest lintDebugpasses.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
UI/scanner-follow-ups.
fastlane/metadataonly adds store metadata.