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

说明:

内置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

     Fat::format(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

    在调用Fat::format函数的地方,增加第三个参数IsEmmcStorage()        

    Fat::format(devicePath, 0, IsEmmcStorage())

 

注意:

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

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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值