首页 > 其他分享 >android 如何修改USB存储在"我的电脑"中显示的label名称

android 如何修改USB存储在"我的电脑"中显示的label名称

时间:2023-03-17 19:05:23浏览次数:37  
标签:tmp USB args label logwrap rc android fsPath


说明:

内置SD卡即是eMMC上的FAT partition,可以指定label。 外置SD card是外部设备,无法指定label。

  • Internal SD card à You can assign label
  • External SD card à You cannot assign label


步骤:

主要是在format时去指定 “–L”  的参数值,并给出label name。具体修改涉及三个文件:

1. /system/vold/Fat.cpp 

添加一个新的format函数,第三个参数为bool isInternalSd:

const char *fsPath, unsigned int numSectors, bool isInternalSd)

     修改新增format函数的实现:


#ifdef MTK_FORMAT_NOT_PARAM_CLUSTER
args[1] = "-O";
args[2] = "android";
close(fd);
if(numSectors)
{
char tmp[32];
snprintf(tmp,sizeof(tmp),"%u",numSectors);
const char *size = tmp;
args[3] = "-s";
args[4] = size;
args[5] = fsPath;
args[6]= NULL;
rc = logwrap(7,args,1);
}
else
{
if(isInternalSd)
{
args[3] = "-L";
args[4] = "YOUR LABEL NAME"; // 修改label,注意长度不能超过11个字符
args[5] = fsPath;
args[6]= NULL;
rc = logwrap(7,args,1);
}
else
{
args[3] = fsPath;
args[4] = NULL;
rc = logwrap(9,args,1);
}
}

#else......
if(numSectors)
{
char tmp[32];
snprintf(tmp,sizeof(tmp),"%u",numSectors);
const char *size = tmp;
args[7] = "-s";
args[8] = size;
args[9] = fsPath;
args[10]= NULL;
rc = logwrap(11,args,1);
}
else
{
if(isInternalSd)
{
args[7] = "-L";
args[8] = "YOUR LABEL NAME"; // 修改label,注意长度不能超过11个字符
args[9] = fsPath;
args[10]= NULL;
rc = logwrap(11,args,1);
}
else
{
args[7] = fsPath;
args[8] = NULL;
rc = logwrap(9,args,1);
}
}
#endif......


2. /system/vold/Fat.h

    添加新增format函数的定义

3. /system/vold/Volume.cpp

IsEmmcStorage()

IsEmmcStorage())


注意:

1. VolumeManger.cpp里面调用Fat::format() 的地方不需要修改

2. 下载image时,需要进行格式化下载

标签:tmp,USB,args,label,logwrap,rc,android,fsPath
From: https://blog.51cto.com/u_15170706/6127833

相关文章