Storage, Filesystems & Partitions
Android storage architecture is divided between raw physical flash partitions (UFS or eMMC), virtualized emulated storage, Linux filesystem mount points, and physical removable microSD volumes.
Emulated Storage vs. Physical Removable MicroSD
When an Android file manager shows "Internal Shared Storage" at /storage/emulated/0, many users assume this is a distinct hardware partition or a virtual SD card. In reality, modern Android utilizes an emulated fuse/sdcardfs layer backed directly by the internal data partition directory /data/media/0. Both paths share the exact same physical flash capacity. Voodoo uses reflection on StorageManager.getStorageVolumes() (API 24+) to verify whether an inserted volume is physically removable (a true microSD card) or emulated.
Voodoo parses /proc/mounts to inspect genuine Linux filesystems: modern flash formats (f2fs, ext4) on modern phones vs legacy MTD NAND formats (yaffs2) on Android 2.3 hardware.
On Android versions prior to API 18, StatFs.getBlockCount() returns 32-bit integers that overflow on storage larger than 2 TB. Voodoo uses safe Long casting and API 18+ 64-bit methods to guarantee accurate storage calculations across all platforms.
How Voodoo Inspects Storage & Mounts
1. Primary Call & API-Level Fallback Chain
Extracted from StorageCollector.kt. Uses StatFs for capacity metrics, parses /proc/mounts for partition filesystems, and reflects on StorageManager for volume objects:
// Excerpt from com.tool3.hardwareinfo.categories.storage.StorageCollector.kt
val dataDir = Environment.getDataDirectory()
val stat = StatFs(dataDir.path)
// Safe 64-bit capacity calculation
val totalBytes = if (Build.VERSION.SDK_INT >= 18) {
ModernStorageHelper.getTotalBytes(stat)
} else {
stat.blockCount.toLong() * stat.blockSize.toLong()
}
// StorageVolume enumeration (API 24+ via reflection for Dalvik 2.3 safety)
val volumes = if (Build.VERSION.SDK_INT >= 24) {
ModernStorageHelper.getStorageVolumes(context)
} else {
emptyList()
}
// Parse Linux /proc/mounts for actual filesystem types (ext4, f2fs, yaffs2)
val mounts = MountsParser.parse()
2. Permission & Privilege Gate
Storage capacity querying via StatFs and mount parsing via /proc/mounts require zero runtime permissions. The app queries filesystem block headers without accessing personal files.
3. Interpretation & Normalization Logic
- Partition Filtering:
MountsParserfilters out hundreds of temporary pseudo-mounts (cgroups, tmpfs, debugfs) to summarize primary physical partitions:/,/system,/data,/cache,/vendor. - Octal Path Decoding: Encoded space characters in mount paths (
\040) are cleanly decoded into readable whitespace.
4. Availability-State Triggers
StorageManager.getStorageVolumes()on Android < 7.0 triggersAvailabilityState.UNSUPPORTED.- When no physical microSD card is inserted, external removable fields are marked
AvailabilityState.UNAVAILABLE.
Subsystem Field Inventory
| Field ID | Display Name | Type | Primary Source / API | Min API |
|---|---|---|---|---|
| storage.internal_total_bytes | Internal Storage Total | INTEGER | StatFs(Environment.getDataDirectory()) | API 1 |
| storage.internal_available_bytes | Internal Storage Available | INTEGER | StatFs.getAvailableBlocksLong() | API 1 |
| storage.internal_fs_type | Internal Filesystem | STRING | /proc/mounts match for /data (f2fs, ext4, yaffs2) | API 1 |
| storage.is_emulated | Primary Storage Emulated | BOOLEAN | Environment.isExternalStorageEmulated() (API 11+) | API 11 |
| storage.removable_volumes | Removable MicroSD Cards | LIST | StorageManager.getStorageVolumes() (API 24+) | API 24 |
| storage.mount_count | Total Active Mount Points | INTEGER | /proc/mounts parsed count | API 1 |