Android OTG U盘无法显示在系统文件管理的修改
文件:frameworks\base\services\core\java\com\android\server\StorageManagerService.java
函数:private void onVolumeCreatedLocked(VolumeInfo vol)
如下修改:
private void onVolumeCreatedLocked(VolumeInfo vol) {
......
if (vol.type == VolumeInfo.TYPE_EMULATED) {
......
} else if (vol.type == VolumeInfo.TYPE_PUBLIC) {
......
// Adoptable public disks are visible to apps, since they meet
// public API requirement of being in a stable location.
/**********************************************************************/
//if (vol.disk.isAdoptable()) { //注释掉这个判断
vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
//}
/**********************************************************************/
......
}
上面的修改,在U盘mount的时候会起作用:
文件:system/vold/model/PublicVolume.cpp
函数:status_t PublicVolume::doMount()
status_t PublicVolume::doMount() {
// TODO: expand to support mounting other filesystems
readMetadata();
......
setInternalPath(mRawPath);
if (getMountFlags() & MountFlags::kVisible) { //这里有判断,使用storage挂载路径
setPath(StringPrintf("/storage/%s", stableName.c_str()));
} else {
setPath(mRawPath);
}
......
if (!(getMountFlags() & MountFlags::kVisible)) { //这里也有判断,会继续执行后面的创建用户空间文件系统
// Not visible to apps, so no need to spin up FUSE
return OK;
}
......
return OK;
}