android文件管理器不显示u盘内容

14 篇文章 5 订阅 ¥99.90 ¥299.90
本文探讨了Android设备上的文件管理器在连接U盘后无法正常显示内容的问题。可能的原因包括文件系统不兼容、USB驱动支持、权限设置等。针对这些问题,提出了解决方案,如格式化U盘为FAT32或NTFS,检查USB调试模式,确保应用具有读取外部存储的权限等。
摘要由CSDN通过智能技术生成
From source codes,
Vold sets the device as adoptable or not based on the flag(encryptable/forceencrypt) as shown
below.
231 if (fs_mgr_is_encryptable(&fstab->recs[i])) {
232 flags |= android::vold::Disk::Flags::kAdoptable;
233 has_adoptable = true;
234 }
Which is further passed to Mountservice, which marks only the adoptable volumes as Visible
devices.
1285 } else if (vol.type == VolumeInfo.TYPE_PUBLIC) {
1286 // TODO: only look at first public partition
1287 if (Objects.equals(StorageManager.UUID_PRIMARY_PHYSICAL, mPrimaryStorageUuid)
1288 && vol.disk.isDefaultPrimary()) {
1289 Slog.v(TAG, "Found primary storage at " + vol);
1290 vol.mountFlags |= VolumeInfo.MOUNT_FLAG_PRIMARY;
1291 vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
1292 }
1293
1294 // Adoptable public disks are visible to apps, since they meet
1295 // public API requirement of being in a stable location.
1296 if (vol.disk.isAdoptable()) {
1297 vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
1298 }
Non adoptable volumes are NOT exposed to apps.
And hence, in vold, while Mounting(), the app-exposed-mountpoint -> /storage/<ID> is not mounted
for invisible devices.
120 if (getMountFlags() & MountFlags::kVisible) {
121 setPath(StringPrintf("/storage/%s", stableName.c_str()));
122 } else {
Settings is a privileged Platform app, shared system uid, so it can call frameworks APIs directly,
which can't be done by CMFilemanager(which is just system app)


[解决方案]
If we want to see the the non-adoptable volumes (like UDisk and Pen-driver via OTG) in
FileManager app, we can modify MountService.java as below , then have a try.
1294 // Adoptable public disks are visible to apps, since they meet
1295 // public API requirement of being in a stable location
- if (vol.disk.isAdoptable()) {
+ if (vol.disk.isAdoptable() || vol.disk.isUsb()) {
1297 vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
1298 }
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

macheria

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值