|
发表于 2020-8-3 11:34:16
7477 浏览 0 回复
android8.0以后的版本出现第三方app没有读写U盘的权限,而系...
1.第三方app无法申请"android.permission.WRITE_MEDIA_STORAGE"。这是系统级别的权限,
解决方式,修改源码:
system/vold/PublicVolume.cpp或者system/vold/model/PublicVolume.cpp
doMount()方法中,
if (!(mFusePid = fork())) {
if (getMountFlags() & MountFlags::kPrimary) {
if (execl(kFusePath, kFusePath,
"-u", "1023", // AID_MEDIA_RW
"-g", "1023", // AID_MEDIA_RW
"-U", std::to_string(getMountUserId()).c_str(),
"-w",
mRawPath.c_str(),
stableName.c_str(),
NULL)) {
PLOG(ERROR) << "Failed to exec";
}
} else {
if (execl(kFusePath, kFusePath,
"-u", "1023", // AID_MEDIA_RW
"-g", "1023", // AID_MEDIA_RW
"-U", std::to_string(getMountUserId()).c_str(),
"-w", //add by jyj
mRawPath.c_str(),
stableName.c_str(),
NULL)) {
PLOG(ERROR) << "Failed to exec";
}
}
给U盘加上-w的参数,传入到system/core/sdcard/sdcard.cpp里面会给根据参数添加权限
|
|
|
|
|
|
|
登录或注册
|