libsnapshot: Check if the vendor is updated from Android S for GRF

In a GRF config, if Vendor partition is updated from Android 12; post
OTA reboot, first stage init will communicate to daemon to check if the
daemon can support socket handoff. If that succeeds, then it is a signal
that the vendor has been updated from Android 12. Use a marker in
/metadata to signal that the vendor was updated. If the marker is present,
then post OTA reboot, userspace snapshot will be used.

Bug: 333854394
Test: OTA
Android U (system) + S (vendor) -> Android V (system) + V (Vendor)

Change-Id: Ie38c4379010789a84e5b44529b407f9f82135271
Signed-off-by: Akilesh Kailash <akailash@google.com>
diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp
index 5d3a273..55cce6e 100644
--- a/init/first_stage_mount.cpp
+++ b/init/first_stage_mount.cpp
@@ -395,12 +395,7 @@
 
     use_snapuserd_ = sm->IsSnapuserdRequired();
     if (use_snapuserd_) {
-        if (sm->UpdateUsesUserSnapshots()) {
-            LaunchFirstStageSnapuserd();
-        } else {
-            LOG(FATAL) << "legacy virtual-ab is no longer supported";
-            return false;
-        }
+        LaunchFirstStageSnapuserd();
     }
 
     sm->SetUeventRegenCallback([this](const std::string& device) -> bool {
diff --git a/init/snapuserd_transition.cpp b/init/snapuserd_transition.cpp
index 9e3ff41..2370bc2 100644
--- a/init/snapuserd_transition.cpp
+++ b/init/snapuserd_transition.cpp
@@ -100,6 +100,10 @@
     }
     if (client->SupportsSecondStageSocketHandoff()) {
         setenv(kSnapuserdFirstStageInfoVar, "socket", 1);
+        auto sm = SnapshotManager::NewForFirstStageMount();
+        if (!sm->MarkSnapuserdFromSystem()) {
+            LOG(ERROR) << "Failed to update MarkSnapuserdFromSystem";
+        }
     }
 
     setenv(kSnapuserdFirstStagePidVar, std::to_string(pid).c_str(), 1);