OSDN Git Service

vold: Allow reset after shutdown
authorSteve Kondik <steve@cyngn.com>
Thu, 28 Jul 2016 01:12:04 +0000 (18:12 -0700)
committerMichael Bestas <mkbestas@lineageos.org>
Sun, 23 Sep 2018 23:23:52 +0000 (02:23 +0300)
 * If we shutdown all volumes (during crypto), vold throws up an
   assert at us when reset() is called due to destroying an
   already destroyed volume. This is actually fine, just return
   an error instead of crashing.

Change-Id: I51f8561da83e27de8e80d74f3a600fb0139d3035

model/VolumeBase.cpp

index 429f134..8cca74e 100644 (file)
@@ -162,7 +162,9 @@ std::shared_ptr<VolumeBase> VolumeBase::findVolume(const std::string& id) {
 }
 
 status_t VolumeBase::create() {
-    CHECK(!mCreated);
+    if (mCreated) {
+        return BAD_VALUE;
+    }
 
     mCreated = true;
     status_t res = doCreate();
@@ -180,7 +182,9 @@ status_t VolumeBase::doCreate() {
 }
 
 status_t VolumeBase::destroy() {
-    CHECK(mCreated);
+    if (!mCreated) {
+        return NO_INIT;
+    }
 
     if (mState == State::kMounted) {
         unmount();