1.通用修改方法包括download等文件夹
package/providers/MediaProvider/src/com/android/providers/media/MediaProvider.java
if (vol.isPrimary()) {
key = "created_default_folders";
} else {
- key = "created_default_folders_" + vol.getMediaStoreVolumeName();
+ //key = "created_default_folders_" + vol.getMediaStoreVolumeName(); //delete by gyx
+ return;
}
2.修改U盘自动创建Android文件夹
system/vold/model/PublicVolume.cpp ->status_t PublicVolume::doMount() 方法内
if (mFsType == "vfat") {
if (vfat::Mount(mDevPath, mRawPath, false, false, false, AID_ROOT,
(isVisible ? AID_MEDIA_RW : AID_EXTERNAL_STORAGE), 0007, true)) {
PLOG(ERROR) << getId() << " failed to mount " << mDevPath;
return -EIO;
}
} else if (mFsType == "exfat") {
把true改成false 该变量(createLost)控制 LOST.DIR 文件夹是否创建
3.system/vold/VolumeManager.cpp->int VolumeManager::setupAppDir(const std::string& path, int32_t appUid, bool fixupExistingOnly) { 方法内
if (volume->getType() == VolumeBase::Type::kPublic) { 该条件下通过路径判断过滤
path = “/storage/xxxx-xxx/Android/data/com.xxxxx.demo/files/” U盘路径
path = “/storage/emulated/Android/data/com.xxxxx.demo/files/” 内置sd路径
4.frameworks/base/core/java/android/app/ContextImpl.java 只需修改此类即可
关键方法
getExternalMediaDirs
getExternalFilesDirs
private File[] ensureExternalDirsExistOrFilter(File[] dirs, boolean tryCreateInProcess)