aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Marshall <tdm.code@gmail.com>2019-07-24 21:12:07 +0200
committerAlessandro Astone <ales.astone@gmail.com>2019-07-25 00:16:46 +0200
commit486c46730f36beb69d48b7a448e4fe68e5eb7b91 (patch)
treef0282a7c7556da18290d72274d6d230601311c7a
parentbc9c7082cf13bb07f9926771f0a6cb9d7370efed (diff)
downloadandroid_bootable_recovery-486c46730f36beb69d48b7a448e4fe68e5eb7b91.tar.gz
android_bootable_recovery-486c46730f36beb69d48b7a448e4fe68e5eb7b91.tar.bz2
android_bootable_recovery-486c46730f36beb69d48b7a448e4fe68e5eb7b91.zip
recovery: Extend mountable check to all volumes and fix volume selection
* In volume manager, check if new volumes are mountable. * Check volumes for mountable for inclusion into update list. * Erase unmountable volumes from volumes vector for consistency with the item array. Change-Id: I89ff6cc05a93afffe5e46b24d70fc368bccaf020
-rw-r--r--recovery.cpp12
-rw-r--r--volume_manager/VolumeBase.cpp8
-rw-r--r--volume_manager/VolumeBase.h3
-rw-r--r--volume_manager/VolumeManager.cpp2
-rw-r--r--volume_manager/include/volume_manager/VolumeManager.h1
5 files changed, 21 insertions, 5 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 2eead17b..aec3a44b 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -1264,13 +1264,19 @@ refresh:
std::vector<VolumeInfo> volumes;
VolumeManager::Instance()->getVolumeInfo(volumes);
- for (auto& vol : volumes) {
- if (vol.mLabel == "emulated") {
+ for (auto vol = volumes.begin(); vol != volumes.end(); /* empty */) {
+ if (vol->mLabel == "emulated") {
if (!userdata_mountable || userdata_encrypted) {
+ vol = volumes.erase(vol);
continue;
}
+ } else if (!vol->mMountable) {
+ vol = volumes.erase(vol);
+ continue;
}
- items.push_back(MenuItem("Choose from " + vol.mLabel));
+
+ items.push_back(MenuItem("Choose from " + vol->mLabel));
+ ++vol;
}
int status = INSTALL_ERROR;
diff --git a/volume_manager/VolumeBase.cpp b/volume_manager/VolumeBase.cpp
index f05ef353..32040fc3 100644
--- a/volume_manager/VolumeBase.cpp
+++ b/volume_manager/VolumeBase.cpp
@@ -35,7 +35,7 @@ namespace android {
namespace volmgr {
VolumeBase::VolumeBase(Type type)
- : mType(type), mMountFlags(0), mCreated(false), mState(State::kUnmounted), mSilent(false) {}
+ : mType(type), mMountFlags(0), mCreated(false), mState(State::kUnmounted), mSilent(false), mMountable(false) {}
VolumeBase::~VolumeBase() {
CHECK(!mCreated);
@@ -131,6 +131,12 @@ status_t VolumeBase::create() {
}
}
setState(State::kUnmounted);
+
+ if (doMount() == OK) {
+ mMountable = true;
+ doUnmount();
+ }
+
return res;
}
diff --git a/volume_manager/VolumeBase.h b/volume_manager/VolumeBase.h
index 6ec6e274..39ba9fde 100644
--- a/volume_manager/VolumeBase.h
+++ b/volume_manager/VolumeBase.h
@@ -82,6 +82,7 @@ class VolumeBase {
int getMountFlags() const { return mMountFlags; }
State getState() const { return mState; }
const std::string& getPath() const { return mPath; }
+ bool isMountable() const { return mMountable; }
status_t setDiskId(const std::string& diskId);
status_t setPartGuid(const std::string& partGuid);
@@ -127,6 +128,8 @@ class VolumeBase {
/* Flag indicating that volume should emit no events */
bool mSilent;
+ bool mMountable;
+
void setState(State state);
DISALLOW_COPY_AND_ASSIGN(VolumeBase);
diff --git a/volume_manager/VolumeManager.cpp b/volume_manager/VolumeManager.cpp
index 3854abaa..203a614a 100644
--- a/volume_manager/VolumeManager.cpp
+++ b/volume_manager/VolumeManager.cpp
@@ -135,7 +135,7 @@ static int process_config(VolumeManager* vm, fstab_rec** data_recp) {
}
VolumeInfo::VolumeInfo(const VolumeBase* vol)
- : mId(vol->getId()), mLabel(vol->getPartLabel()), mPath(vol->getPath()) {
+ : mId(vol->getId()), mLabel(vol->getPartLabel()), mPath(vol->getPath()), mMountable(vol->isMountable()) {
// Empty
}
diff --git a/volume_manager/include/volume_manager/VolumeManager.h b/volume_manager/include/volume_manager/VolumeManager.h
index 67ccdad0..a9ee835d 100644
--- a/volume_manager/include/volume_manager/VolumeManager.h
+++ b/volume_manager/include/volume_manager/VolumeManager.h
@@ -48,6 +48,7 @@ class VolumeInfo {
std::string mId;
std::string mLabel;
std::string mPath;
+ bool mMountable;
};
class VolumeManager {