I lost whole day fighting with something trivial, but now I just give up and need your help.
In new Oreo API for reading app code/data/cache/ size we need storage UUID (StorageStatsManager.queryStatsForUid(UUID storageUuid, int uid)).
The storage UUID is possible to fetch from StorageManager.getStorageVolumes() which returns list of all storages which contains also the UUIDs.
And there the problem begins: The UUID from returned list is in String format while StorageStatsManager.queryStatsForUid(UUID storageUuid, int uid) requires UUID object - nothing simplier - there exist method UUID.fromString(String name) which converts it in a while.. but wait, the UUID value from StorageManager list is incompatibile with UUID parser - WHAT?! I've checked on 2 devices (one with Oreo and one with Nougat), both with external memory and for each device I get 2 storages:
Can anyone explain me what am I doing wrong and how should I get UUID for external storage? Or just new API StorageStatsManager.queryStatsForUid(UUID storageUuid, int uid) is useless as we are unable to get storage UUID?
FYI:
Whats more there is another StackOverflow question where usage of this API is marked as correct solution: https://stackoverflow.com/a/44708209/1946366 what makes me even more frustrated...
StorageManager is the interface to the systems storage service. The storage manager handles storage-related items such as Opaque Binary Blobs (OBBs). OBBs contain a filesystem that maybe be encrypted on disk and mounted on-demand from an application.
Actually the fromString(uuid_string) takes a "long" UUID (with like 4 or 8 parts can't remember exactly).
However the following works perfectly:
UUID.nameUUIDFromBytes(sv.getUuid().getBytes());
I found that this is raised already bug on Android: https://issuetracker.google.com/issues/62982912 so I think that my questions is unanswerable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With