summaryrefslogtreecommitdiffstats
path: root/install/snapshot_utils.cpp
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-01-07 22:00:52 +0100
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-01-07 22:00:52 +0100
commit1bbec589b72f93521c2cd02ffc0831553241848c (patch)
tree1da44d0a08f9c32aa6b7bfdca6cb579576cb634c /install/snapshot_utils.cpp
parentMerge "Link libvndksupport dynamically instead of statically." am: 8b9ac5b83d am: dddedcc3de am: 58c0120969 (diff)
parentMerge "Mount snapshotted /system in Virtual A/B devices" am: 5ee782079a am: bc4b2b44e9 (diff)
downloadandroid_bootable_recovery-1bbec589b72f93521c2cd02ffc0831553241848c.tar
android_bootable_recovery-1bbec589b72f93521c2cd02ffc0831553241848c.tar.gz
android_bootable_recovery-1bbec589b72f93521c2cd02ffc0831553241848c.tar.bz2
android_bootable_recovery-1bbec589b72f93521c2cd02ffc0831553241848c.tar.lz
android_bootable_recovery-1bbec589b72f93521c2cd02ffc0831553241848c.tar.xz
android_bootable_recovery-1bbec589b72f93521c2cd02ffc0831553241848c.tar.zst
android_bootable_recovery-1bbec589b72f93521c2cd02ffc0831553241848c.zip
Diffstat (limited to 'install/snapshot_utils.cpp')
-rw-r--r--install/snapshot_utils.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/install/snapshot_utils.cpp b/install/snapshot_utils.cpp
index 69da5eea0..7235e67c8 100644
--- a/install/snapshot_utils.cpp
+++ b/install/snapshot_utils.cpp
@@ -15,6 +15,7 @@
* limitations under the License.
*/
+#include <android-base/logging.h>
#include <android-base/properties.h>
#include <libsnapshot/snapshot.h>
@@ -22,6 +23,7 @@
#include "recovery_ui/ui.h"
#include "recovery_utils/roots.h"
+using android::snapshot::CreateResult;
using android::snapshot::SnapshotManager;
bool FinishPendingSnapshotMerges(Device* device) {
@@ -47,3 +49,26 @@ bool FinishPendingSnapshotMerges(Device* device) {
}
return true;
}
+
+bool CreateSnapshotPartitions() {
+ if (!android::base::GetBoolProperty("ro.virtual_ab.enabled", false)) {
+ // If the device does not support Virtual A/B, there's no need to create
+ // snapshot devices.
+ return true;
+ }
+
+ auto sm = SnapshotManager::NewForFirstStageMount();
+ if (!sm) {
+ // SnapshotManager could not be created. The device is still in a
+ // consistent state and can continue with the mounting of the existing
+ // devices, but cannot initialize snapshot devices.
+ LOG(WARNING) << "Could not create SnapshotManager";
+ return true;
+ }
+
+ auto ret = sm->RecoveryCreateSnapshotDevices();
+ if (ret == CreateResult::ERROR) {
+ return false;
+ }
+ return true;
+}