从Android StorageManager获取的存储UUID无效? [英] Invalid UUID of storage gained from Android StorageManager?

查看:652
本文介绍了从Android StorageManager获取的存储UUID无效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我整天都在争夺一些琐碎的东西,但现在我只是放弃了,需要您的帮助.

I lost whole day fighting with something trivial, but now I just give up and need your help.

在用于读取应用程序代码/数据/缓存/大小的新Oreo API中,我们需要存储UUID(

In new Oreo API for reading app code/data/cache/ size we need storage UUID (StorageStatsManager.queryStatsForUid(UUID storageUuid, int uid)).

可以从 StorageManager中获取存储UUID. getStorageVolumes()返回所有包含UUID的存储的列表.

The storage UUID is possible to fetch from StorageManager.getStorageVolumes() which returns list of all storages which contains also the UUIDs.

问题开始了,:返回的列表中的UUID为String格式,而

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:

  1. 具有UUID的内部设备内存等于空"-可以很好地满足文档中的描述
  2. 外部存储卡的UUID值格式为"4012-1A4B",这是无效的UUID格式,并导致UUID.fromString抛出IllegalArgumentException.
  1. Internal device memory with UUID equals "null" - thats fine as this is described in documentation
  2. External card storage with UUID value in format like "4012-1A4B" what is invalid UUID format and causes UUID.fromString throws IllegalArgumentException.

谁能向我解释我在做什么错,我应该如何获取用于外部存储的UUID?或者只是新的API StorageStatsManager .queryStatsForUid(UUID storageUuid, int uid)没有用,因为我们无法获取存储UUID?

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?

仅供参考:

此外,还有另一个StackOverflow问题,其中此API的使用被标记为正确的解决方案: https://stackoverflow.com/a/44708209/1946366 是什么让我更加沮丧...

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...

推荐答案

我发现这已经在Android上引发了错误: https://issuetracker.google.com/issues/62982912 所以我认为我的问题无法回答.

I found that this is raised already bug on Android: https://issuetracker.google.com/issues/62982912 so I think that my questions is unanswerable.

这篇关于从Android StorageManager获取的存储UUID无效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆