Android修改Vold支持PCI-E设备自动挂载,阿里出品

+++ b/system/vold/Disk.cpp

@@ -68,6 +68,7 @@ static const unsigned int kMajorBlockScsiP = 135;

static const unsigned int kMajorBlockMmc = 179;

static const unsigned int kMajorBlockExperimentalMin = 240;

static const unsigned int kMajorBlockExperimentalMax = 254;

+static const unsigned int kMajorBlockPcie = 259;

static const char* kGptBasicData = “EBD0A0A2-B9E5-4433-87C0-68B6B72699C7”;

static const char* kGptAndroidMeta = “19A710A2-B3CA-11E4-B026-10604B889DCF”;

@@ -261,6 +262,18 @@ status_t Disk::readMetadata() {

}

break;

}

  • case kMajorBlockPcie: {

  •    std::string path(mSysPath + "/device/device/vendor");
    
  •    std::string tmp;
    
  •    if (!ReadFileToString(path, &tmp)) {
    
  •        PLOG(WARNING) << "Failed to read vendor from " << path;
    
  •        return -errno;
    
  •    }
    
  •    mLabel = tmp;
    
  •    break;
    
  • }

default: {

if (isVirtioBlkDevice(majorId)) {

LOG(DEBUG) << "Recognized experimental block major ID " << majorId

@@ -556,6 +569,14 @@ int Disk::getMaxMinors() {

}

return atoi(tmp.c_str());

}

  • case kMajorBlockPcie: {

  •    std::string tmp;
    
  •    if (!ReadFileToString(kSysfsMmcMaxMinors, &tmp)) {
    
  •        LOG(ERROR) << "Failed to read max minors";
    
  •        return -errno;
    
  •    }
    
  •    return atoi(tmp.c_str());
    
  • }

default: {

if (isVirtioBlkDevice(majorId)) {

// drivers/block/virtio_blk.c has “#define PART_BITS 4”, so max is

diff --git a/system/vold/Disk.h b/system/vold/Disk.h

index 77ec7df…6662fa4 100644

— a/system/vold/Disk.h

+++ b/system/vold/Disk.h

@@ -52,6 +52,7 @@ public:

kUsb = 1 << 3,

/* Flag that disk is EMMC internal */

kEmmc = 1 << 4,

  •    kPcie = 1 << 5,
    

};

const std::string& getId() { return mId; }

diff --git a/system/vold/VolumeManager.cpp b/system/vold/VolumeManager.cpp

index 5cc60a1…f766c5a 100644

— a/system/vold/VolumeManager.cpp

+++ b/system/vold/VolumeManager.cpp

@@ -302,11 +302,14 @@

《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》

【docs.qq.com/doc/DSkNLaERkbnFoS0ZF】 完整资料开源分享

void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {

// emulator-specific; see Disk.cpp for details) devices are SD,

// and that everything else is USB

int flags = source->getFlags();

  •            LOG(VERBOSE) << "handleBlockEvent with action  kAdd flags" << flags;
    

if (major == kMajorBlockMmc

|| (android::vold::IsRunningInEmulator()

&& major >= (int) kMajorBlockExperimentalMin

文末

架构师不是天生的,是在项目中磨练起来的,所以,我们学了技术就需要结合项目进行实战训练,那么在Android里面最常用的架构无外乎 MVC,MVP,MVVM,但是这些思想如果和模块化,层次化,组件化混和在一起,那就不是一件那么简单的事了,我们需要一个真正身经百战的架构师才能讲解透彻其中蕴含的深理。

Android修改Vold支持PCI-E设备自动挂载,阿里出品

Android修改Vold支持PCI-E设备自动挂载,阿里出品

一线互联网Android面试题总结含详解(初级到高级专题)

Android修改Vold支持PCI-E设备自动挂载,阿里出品

VeEUqW-1640924880794)]

[外链图片转存中…(img-7rvvs7X2-1640924880795)]

一线互联网Android面试题总结含详解(初级到高级专题)

[外链图片转存中…(img-JbPkquR3-1640924880796)]

本文已被CODING开源项目:《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》收录

上一篇:Disk Clean Pro Mac破解版是一款功能强大的磁盘清理工具


下一篇:开发常用知识点