From 73a7a85c853368c33d0313bead59c0159adedbd1 Mon Sep 17 00:00:00 2001 From: Risan Date: Fri, 7 Feb 2020 18:03:44 +0900 Subject: [PATCH] Passed kUsb and kSd flags Initially, we were thinking to pass kInternal for non usb drive/sd card drive (for local external storage like directory shared from ChromeOS). Fortunately, the DocumentsUI logic apparently has TYPE_LOCAL with R.drawable.ic_root_smartphone (that is overlayable) for external storage other than TYPE_USB and TYPE_SD. Therefore, instead of creating a kInternal flags, we can just passed kUsb and kSd and not passing anything for "internal external storage" - which will render ic_root_usb, ic_root_sd, and ic_root_smartphone as icons accordingly. And since ic_root_smartphone is already overlayable, we could overlayed in /vendor - which effectively is what we initially wanted when thinking of introducing kInternal flag. Bug: 132796154 Test: Customize flags in /vendor for different devices and DocumentsUI shows the ic_root_smartphone (which can be overlayed) when kUsb is not passed, and USB icon when kUsb is passed. Change-Id: I55f13e214bbb2aeed96b6950bcf391121174c354 --- VolumeManager.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/VolumeManager.cpp b/VolumeManager.cpp index 0c81cb7..bb62441 100644 --- a/VolumeManager.cpp +++ b/VolumeManager.cpp @@ -899,18 +899,19 @@ int VolumeManager::destroyObb(const std::string& volId) { int VolumeManager::createStubVolume(const std::string& sourcePath, const std::string& mountPath, const std::string& fsType, const std::string& fsUuid, - const std::string& fsLabel, int32_t flags __unused, + const std::string& fsLabel, int32_t flags, std::string* outVolId) { dev_t stubId = --mNextStubId; auto vol = std::shared_ptr( new android::vold::StubVolume(stubId, sourcePath, mountPath, fsType, fsUuid, fsLabel)); - // TODO (b/132796154): Passed each supported flags explicitly here. + int32_t passedFlags = android::vold::Disk::Flags::kStub; + passedFlags |= (flags & android::vold::Disk::Flags::kUsb); + passedFlags |= (flags & android::vold::Disk::Flags::kSd); // StubDisk doesn't have device node corresponds to it. So, a fake device - // number is used. The supported flags will be infered from the - // currently-unused flags parameter. + // number is used. auto disk = std::shared_ptr( - new android::vold::Disk("stub", stubId, "stub", android::vold::Disk::Flags::kStub)); + new android::vold::Disk("stub", stubId, "stub", passedFlags)); disk->initializePartition(vol); handleDiskAdded(disk); *outVolId = vol->getId();