Files
philips-tv-speicher-voll/patches/usb-freesize/IMPLEMENTATION.md

1.3 KiB

USB free-size implementation

The exact stock target is tvfw.jar!/classes.dex, UsbVolumeListerImpl.getVolumes(String), code_off=0x17b5e0. At DEX PC 0x0133 it reads only sys.mtk.dmremoteservice.ready; when the value is not 1, the size assignment is skipped and constructor-default zero is published.

MediaTek DMServer$4 derives MountPoint sizes as StatFs bytes divided by 1,024, so those fields are KiB. UsbVolumeListerImpl divides by 1,024 again, making its public field contract MiB. The fallback must therefore use StatFs.getAvailableBytes()/1,048,576, with long arithmetic.

Accept DeviceManager values only when the service is ready, total is positive, and 0 <= free <= total. Otherwise query the actual mounted VolumeInfo path. A successful query may legitimately return zero; a missing path, removal race, permission error, or invalid range must remain UNKNOWN/omitted—not numeric zero. The same decision applies to public, private/adopted and emulated volumes.

PATCH.diff is the source-level specification; SMALI-PATCH.md records the DEX integration boundary. tools/test_usb_size_policy.py validates both sources, property states, >2-TiB arithmetic, true zero and unknown. Deployment still requires a rebuilt tvfw shared-library artifact plus client/preopt and AVB testing.