aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-01-11 00:00:41 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-01-11 00:00:41 +0000
commit91574ad0f22b98349070194e519404c42c608f8c (patch)
treefa474dbcd1043cf932a0277d2e3abcdbfd9391ef
parentea01a56c2d25a95bd6cb00f49dc28fdb5e7e3e38 (diff)
parent9fd1bd240e094a0f45f998a58039bca9c6578836 (diff)
downloadrecovery-android13-d3-s1-release.tar.gz
Snap for 9474727 from 9fd1bd240e094a0f45f998a58039bca9c6578836 to tm-d3-releaseandroid-13.0.0_r57android13-d3-s1-release
Change-Id: Ifefdc00f4a8f8b8561758a5d1c8ce135d928613f
-rw-r--r--update_verifier/Android.bp4
-rw-r--r--update_verifier/include/update_verifier/update_verifier.h5
-rw-r--r--update_verifier/update_verifier.cpp22
3 files changed, 31 insertions, 0 deletions
diff --git a/update_verifier/Android.bp b/update_verifier/Android.bp
index 220b007f..cb97bd1f 100644
--- a/update_verifier/Android.bp
+++ b/update_verifier/Android.bp
@@ -73,6 +73,10 @@ cc_library_static {
"libvold_binder",
],
+ whole_static_libs: [
+ "libsnapshot_snapuserd",
+ ],
+
shared_libs: [
"android.hardware.boot@1.0",
"libbase",
diff --git a/update_verifier/include/update_verifier/update_verifier.h b/update_verifier/include/update_verifier/update_verifier.h
index 4c64b1ea..0cccc907 100644
--- a/update_verifier/include/update_verifier/update_verifier.h
+++ b/update_verifier/include/update_verifier/update_verifier.h
@@ -21,6 +21,7 @@
#include <string>
#include <vector>
+#include <snapuserd/snapuserd_client.h>
#include "otautil/rangeset.h"
// The update verifier performs verification upon the first boot to a new slot on A/B devices.
@@ -68,4 +69,8 @@ class UpdateVerifier {
// The function to read the device property; default value: android::base::GetProperty()
std::function<std::string(const std::string&)> property_reader_;
+
+ // Check if snapuserd daemon has already completed the update verification
+ // Applicable only for VABC with userspace snapshots
+ bool CheckVerificationStatus();
};
diff --git a/update_verifier/update_verifier.cpp b/update_verifier/update_verifier.cpp
index a042f900..88fcfa50 100644
--- a/update_verifier/update_verifier.cpp
+++ b/update_verifier/update_verifier.cpp
@@ -52,6 +52,7 @@
#include <future>
#include <thread>
+#include <android-base/chrono_utils.h>
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/parseint.h>
@@ -188,7 +189,28 @@ bool UpdateVerifier::ReadBlocks(const std::string partition_name,
return ret;
}
+bool UpdateVerifier::CheckVerificationStatus() {
+ auto client =
+ android::snapshot::SnapuserdClient::Connect(android::snapshot::kSnapuserdSocket, 5s);
+ if (!client) {
+ LOG(ERROR) << "Unable to connect to snapuserd";
+ return false;
+ }
+
+ return client->QueryUpdateVerification();
+}
+
bool UpdateVerifier::VerifyPartitions() {
+ const bool userspace_snapshots =
+ android::base::GetBoolProperty("ro.virtual_ab.userspace.snapshots.enabled", false);
+
+ if (userspace_snapshots && CheckVerificationStatus()) {
+ LOG(INFO) << "Partitions verified by snapuserd daemon";
+ return true;
+ }
+
+ LOG(INFO) << "Partitions not verified by snapuserd daemon";
+
auto dm_block_devices = FindDmPartitions();
if (dm_block_devices.empty()) {
LOG(ERROR) << "No dm-enabled block device is found.";