diff --git a/cc/Android.bp b/cc/Android.bp
index 93d9aa2..8c86eb7 100644
--- a/cc/Android.bp
+++ b/cc/Android.bp
@@ -17,7 +17,6 @@
         "soong-fuzz",
         "soong-genrule",
         "soong-multitree",
-        "soong-snapshot",
         "soong-testing",
         "soong-tradefed",
     ],
@@ -45,12 +44,10 @@
         "sabi.go",
         "sdk.go",
         "snapshot_prebuilt.go",
-        "snapshot_utils.go",
         "stl.go",
         "strip.go",
         "tidy.go",
         "util.go",
-        "vendor_snapshot.go",
         "vndk.go",
         "vndk_prebuilt.go",
 
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 20673e8..5fe71f0 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -15,8 +15,6 @@
 package cc
 
 import (
-	"github.com/google/blueprint/proptools"
-
 	"fmt"
 	"io"
 	"path/filepath"
@@ -477,79 +475,6 @@
 	})
 }
 
-func (c *snapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
-	// Each vendor snapshot is exported to androidMk only when BOARD_VNDK_VERSION != current
-	// and the version of the prebuilt is same as BOARD_VNDK_VERSION.
-	if c.shared() {
-		entries.Class = "SHARED_LIBRARIES"
-	} else if c.static() {
-		entries.Class = "STATIC_LIBRARIES"
-	} else if c.header() {
-		entries.Class = "HEADER_LIBRARIES"
-	}
-
-	entries.SubName = ""
-
-	if c.IsSanitizerEnabled(cfi) {
-		entries.SubName += ".cfi"
-	} else if c.IsSanitizerEnabled(Hwasan) {
-		entries.SubName += ".hwasan"
-	}
-
-	entries.SubName += c.baseProperties.Androidmk_suffix
-
-	entries.ExtraEntries = append(entries.ExtraEntries, func(_ android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
-		c.libraryDecorator.androidMkWriteExportedFlags(entries)
-
-		if c.shared() || c.static() {
-			src := c.path.String()
-			// For static libraries which aren't installed, directly use Src to extract filename.
-			// This is safe: generated snapshot modules have a real path as Src, not a module
-			if c.static() {
-				src = proptools.String(c.properties.Src)
-			}
-			path, file := filepath.Split(src)
-			stem, suffix, ext := android.SplitFileExt(file)
-			entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
-			entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
-			entries.SetString("LOCAL_MODULE_STEM", stem)
-			if c.shared() {
-				entries.SetString("LOCAL_MODULE_PATH", path)
-			}
-			if c.tocFile.Valid() {
-				entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String())
-			}
-
-			if c.shared() && len(c.Properties.Overrides) > 0 {
-				entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, c.Properties.Overrides), " "))
-			}
-		}
-
-		if !c.shared() { // static or header
-			entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
-		}
-	})
-}
-
-func (c *snapshotBinaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
-	entries.Class = "EXECUTABLES"
-	entries.SubName = c.baseProperties.Androidmk_suffix
-}
-
-func (c *snapshotObjectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
-	entries.Class = "STATIC_LIBRARIES"
-	entries.SubName = c.baseProperties.Androidmk_suffix
-
-	entries.ExtraFooters = append(entries.ExtraFooters,
-		func(w io.Writer, name, prefix, moduleDir string) {
-			out := entries.OutputFile.Path()
-			varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName)
-
-			fmt.Fprintf(w, "\n%s := %s\n", varname, out.String())
-			fmt.Fprintln(w, ".KATI_READONLY: "+varname)
-		})
-}
-
 func (c *ndkPrebuiltStlLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
 	entries.Class = "SHARED_LIBRARIES"
 }
diff --git a/cc/cc.go b/cc/cc.go
index fb5d096..2fa4b3b 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -35,7 +35,6 @@
 	"android/soong/fuzz"
 	"android/soong/genrule"
 	"android/soong/multitree"
-	"android/soong/snapshot"
 )
 
 func init() {
@@ -347,11 +346,6 @@
 	// see soong/cc/config/vndk.go
 	MustUseVendorVariant bool `blueprint:"mutated"`
 
-	// Used by vendor snapshot to record dependencies from snapshot modules.
-	SnapshotSharedLibs  []string `blueprint:"mutated"`
-	SnapshotStaticLibs  []string `blueprint:"mutated"`
-	SnapshotRuntimeLibs []string `blueprint:"mutated"`
-
 	Installable *bool `android:"arch_variant"`
 
 	// Set by factories of module types that can only be referenced from variants compiled against
@@ -364,20 +358,6 @@
 	// variant to have a ".sdk" suffix.
 	SdkAndPlatformVariantVisibleToMake bool `blueprint:"mutated"`
 
-	// Normally Soong uses the directory structure to decide which modules
-	// should be included (framework) or excluded (non-framework) from the
-	// different snapshots (vendor, recovery, etc.), but this property
-	// allows a partner to exclude a module normally thought of as a
-	// framework module from the vendor snapshot.
-	Exclude_from_vendor_snapshot *bool
-
-	// Normally Soong uses the directory structure to decide which modules
-	// should be included (framework) or excluded (non-framework) from the
-	// different snapshots (vendor, recovery, etc.), but this property
-	// allows a partner to exclude a module normally thought of as a
-	// framework module from the recovery snapshot.
-	Exclude_from_recovery_snapshot *bool
-
 	// List of APEXes that this module has private access to for testing purpose. The module
 	// can depend on libraries that are not exported by the APEXes and use private symbols
 	// from the exported libraries.
@@ -960,8 +940,6 @@
 		"IsVndkSp":               c.IsVndkSp(),
 		"IsLlndk":                c.IsLlndk(),
 		"IsLlndkPublic":          c.IsLlndkPublic(),
-		"IsSnapshotLibrary":      c.IsSnapshotLibrary(),
-		"IsSnapshotPrebuilt":     c.IsSnapshotPrebuilt(),
 		"IsVendorPublicLibrary":  c.IsVendorPublicLibrary(),
 		"ApexSdkVersion":         c.apexSdkVersion,
 		"TestFor":                c.TestFor(),
@@ -1513,14 +1491,6 @@
 	return false
 }
 
-func (c *Module) ExcludeFromVendorSnapshot() bool {
-	return Bool(c.Properties.Exclude_from_vendor_snapshot)
-}
-
-func (c *Module) ExcludeFromRecoverySnapshot() bool {
-	return Bool(c.Properties.Exclude_from_recovery_snapshot)
-}
-
 func isBionic(name string) bool {
 	switch name {
 	case "libc", "libm", "libdl", "libdl_android", "linker":
@@ -2152,14 +2122,6 @@
 		c.outputFile = android.OptionalPathForPath(outputFile)
 
 		c.maybeUnhideFromMake()
-
-		// glob exported headers for snapshot, if BOARD_VNDK_VERSION is current or
-		// RECOVERY_SNAPSHOT_VERSION is current.
-		if i, ok := c.linker.(snapshotLibraryInterface); ok {
-			if ShouldCollectHeadersForSnapshot(ctx, c, apexInfo) {
-				i.collectHeadersForSnapshot(ctx)
-			}
-		}
 	}
 	if c.testModule {
 		android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
@@ -2438,31 +2400,6 @@
 	return apiImportInfo
 }
 
-func GetSnapshot(c LinkableInterface, snapshotInfo **SnapshotInfo, actx android.BottomUpMutatorContext) SnapshotInfo {
-	// Only device modules with BOARD_VNDK_VERSION uses snapshot.  Others use the zero value of
-	// SnapshotInfo, which provides no mappings.
-	if *snapshotInfo == nil && c.Device() {
-		// Only retrieve the snapshot on demand in order to avoid circular dependencies
-		// between the modules in the snapshot and the snapshot itself.
-		var snapshotModule []blueprint.Module
-		if c.InVendor() && c.VndkVersion() == actx.DeviceConfig().VndkVersion() && actx.OtherModuleExists("vendor_snapshot") {
-			snapshotModule = actx.AddVariationDependencies(nil, nil, "vendor_snapshot")
-		} else if recoverySnapshotVersion := actx.DeviceConfig().RecoverySnapshotVersion(); recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && c.InRecovery() && actx.OtherModuleExists("recovery_snapshot") {
-			snapshotModule = actx.AddVariationDependencies(nil, nil, "recovery_snapshot")
-		}
-		if len(snapshotModule) > 0 && snapshotModule[0] != nil {
-			snapshot, _ := android.OtherModuleProvider(actx, snapshotModule[0], SnapshotInfoProvider)
-			*snapshotInfo = &snapshot
-			// republish the snapshot for use in later mutators on this module
-			android.SetProvider(actx, SnapshotInfoProvider, snapshot)
-		}
-	}
-	if *snapshotInfo == nil {
-		*snapshotInfo = &SnapshotInfo{}
-	}
-	return **snapshotInfo
-}
-
 func GetReplaceModuleName(lib string, replaceMap map[string]string) string {
 	if snapshot, ok := replaceMap[lib]; ok {
 		return snapshot
@@ -2471,44 +2408,35 @@
 	return lib
 }
 
-// RewriteLibs takes a list of names of shared libraries and scans it for three types
+// FilterNdkLibs takes a list of names of shared libraries and scans it for two types
 // of names:
 //
-// 1. Name of an NDK library that refers to a prebuilt module.
-//
-//	For each of these, it adds the name of the prebuilt module (which will be in
-//	prebuilts/ndk) to the list of nonvariant libs.
-//
-// 2. Name of an NDK library that refers to an ndk_library module.
+// 1. Name of an NDK library that refers to an ndk_library module.
 //
 //	For each of these, it adds the name of the ndk_library module to the list of
 //	variant libs.
 //
-// 3. Anything else (so anything that isn't an NDK library).
+// 2. Anything else (so anything that isn't an NDK library).
 //
 //	It adds these to the nonvariantLibs list.
 //
 // The caller can then know to add the variantLibs dependencies differently from the
 // nonvariantLibs
-func RewriteLibs(c LinkableInterface, snapshotInfo **SnapshotInfo, actx android.BottomUpMutatorContext, config android.Config, list []string) (nonvariantLibs []string, variantLibs []string) {
+func FilterNdkLibs(c LinkableInterface, config android.Config, list []string) (nonvariantLibs []string, variantLibs []string) {
 	variantLibs = []string{}
 
 	nonvariantLibs = []string{}
 	for _, entry := range list {
 		// strip #version suffix out
 		name, _ := StubsLibNameAndVersion(entry)
-		if c.InRecovery() {
-			nonvariantLibs = append(nonvariantLibs, GetReplaceModuleName(entry, GetSnapshot(c, snapshotInfo, actx).SharedLibs))
-		} else if c.UseSdk() && inList(name, *getNDKKnownLibs(config)) {
+		if c.UseSdk() && inList(name, *getNDKKnownLibs(config)) {
 			variantLibs = append(variantLibs, name+ndkLibrarySuffix)
-		} else if c.UseVndk() {
-			nonvariantLibs = append(nonvariantLibs, GetReplaceModuleName(entry, GetSnapshot(c, snapshotInfo, actx).SharedLibs))
 		} else {
-			// put name#version back
 			nonvariantLibs = append(nonvariantLibs, entry)
 		}
 	}
 	return nonvariantLibs, variantLibs
+
 }
 
 func rewriteLibsForApiImports(c LinkableInterface, libs []string, replaceList map[string]string, config android.Config) ([]string, []string) {
@@ -2580,18 +2508,12 @@
 
 	c.Properties.AndroidMkSystemSharedLibs = deps.SystemSharedLibs
 
-	var snapshotInfo *SnapshotInfo
-
 	variantNdkLibs := []string{}
 	variantLateNdkLibs := []string{}
 	if ctx.Os() == android.Android {
-		deps.SharedLibs, variantNdkLibs = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.SharedLibs)
-		deps.LateSharedLibs, variantLateNdkLibs = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.LateSharedLibs)
-		deps.ReexportSharedLibHeaders, _ = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.ReexportSharedLibHeaders)
-
-		for idx, lib := range deps.RuntimeLibs {
-			deps.RuntimeLibs[idx] = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).SharedLibs)
-		}
+		deps.SharedLibs, variantNdkLibs = FilterNdkLibs(c, ctx.Config(), deps.SharedLibs)
+		deps.LateSharedLibs, variantLateNdkLibs = FilterNdkLibs(c, ctx.Config(), deps.LateSharedLibs)
+		deps.ReexportSharedLibHeaders, _ = FilterNdkLibs(c, ctx.Config(), deps.ReexportSharedLibHeaders)
 	}
 
 	for _, lib := range deps.HeaderLibs {
@@ -2604,7 +2526,6 @@
 		if c.shouldUseApiSurface() {
 			lib = GetReplaceModuleName(lib, apiImportInfo.HeaderLibs)
 		}
-		lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).HeaderLibs)
 
 		if c.isNDKStubLibrary() {
 			// ndk_headers do not have any variations
@@ -2630,8 +2551,6 @@
 	for _, lib := range deps.WholeStaticLibs {
 		depTag := libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: true, reexportFlags: true}
 
-		lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)
-
 		actx.AddVariationDependencies([]blueprint.Variation{
 			{Mutator: "link", Variation: "static"},
 		}, depTag, lib)
@@ -2646,8 +2565,6 @@
 			depTag.excludeInApex = true
 		}
 
-		lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)
-
 		actx.AddVariationDependencies([]blueprint.Variation{
 			{Mutator: "link", Variation: "static"},
 		}, depTag, lib)
@@ -2660,7 +2577,7 @@
 		depTag := libraryDependencyTag{Kind: staticLibraryDependency, staticUnwinder: true}
 		actx.AddVariationDependencies([]blueprint.Variation{
 			{Mutator: "link", Variation: "static"},
-		}, depTag, GetReplaceModuleName(staticUnwinder(actx), GetSnapshot(c, &snapshotInfo, actx).StaticLibs))
+		}, depTag, staticUnwinder(actx))
 	}
 
 	// shared lib names without the #version suffix
@@ -2701,14 +2618,14 @@
 		depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency}
 		actx.AddVariationDependencies([]blueprint.Variation{
 			{Mutator: "link", Variation: "static"},
-		}, depTag, GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs))
+		}, depTag, lib)
 	}
 
 	for _, lib := range deps.UnexportedStaticLibs {
 		depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency, unexportedSymbols: true}
 		actx.AddVariationDependencies([]blueprint.Variation{
 			{Mutator: "link", Variation: "static"},
-		}, depTag, GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs))
+		}, depTag, lib)
 	}
 
 	for _, lib := range deps.LateSharedLibs {
@@ -2749,11 +2666,11 @@
 	actx.AddVariationDependencies(crtVariations, objDepTag, deps.ObjFiles...)
 	for _, crt := range deps.CrtBegin {
 		actx.AddVariationDependencies(crtVariations, CrtBeginDepTag,
-			GetReplaceModuleName(crt, GetSnapshot(c, &snapshotInfo, actx).Objects))
+			crt)
 	}
 	for _, crt := range deps.CrtEnd {
 		actx.AddVariationDependencies(crtVariations, CrtEndDepTag,
-			GetReplaceModuleName(crt, GetSnapshot(c, &snapshotInfo, actx).Objects))
+			crt)
 	}
 	if deps.DynamicLinker != "" {
 		actx.AddDependency(c, dynamicLinkerDepTag, deps.DynamicLinker)
@@ -2786,7 +2703,7 @@
 			actx.AddVariationDependencies([]blueprint.Variation{
 				c.ImageVariation(),
 				{Mutator: "link", Variation: "shared"},
-			}, vndkExtDepTag, GetReplaceModuleName(vndkdep.getVndkExtendsModuleName(), GetSnapshot(c, &snapshotInfo, actx).SharedLibs))
+			}, vndkExtDepTag, vndkdep.getVndkExtendsModuleName())
 		}
 	}
 
@@ -3394,8 +3311,6 @@
 				// they merely serve as Make dependencies and do not affect this lib itself.
 				c.Properties.AndroidMkSharedLibs = append(
 					c.Properties.AndroidMkSharedLibs, makeLibName)
-				// Record BaseLibName for snapshots.
-				c.Properties.SnapshotSharedLibs = append(c.Properties.SnapshotSharedLibs, BaseLibName(depName))
 			case libDepTag.static():
 				if libDepTag.wholeStatic {
 					c.Properties.AndroidMkWholeStaticLibs = append(
@@ -3404,8 +3319,6 @@
 					c.Properties.AndroidMkStaticLibs = append(
 						c.Properties.AndroidMkStaticLibs, makeLibName)
 				}
-				// Record BaseLibName for snapshots.
-				c.Properties.SnapshotStaticLibs = append(c.Properties.SnapshotStaticLibs, BaseLibName(depName))
 			}
 		} else if !c.IsStubs() {
 			// Stubs lib doesn't link to the runtime lib, object, crt, etc. dependencies.
@@ -3414,8 +3327,6 @@
 			case runtimeDepTag:
 				c.Properties.AndroidMkRuntimeLibs = append(
 					c.Properties.AndroidMkRuntimeLibs, MakeLibName(ctx, c, ccDep, ccDep.BaseModuleName())+libDepTag.makeSuffix)
-				// Record BaseLibName for snapshots.
-				c.Properties.SnapshotRuntimeLibs = append(c.Properties.SnapshotRuntimeLibs, BaseLibName(depName))
 			case objDepTag:
 				depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path())
 			case CrtBeginDepTag:
@@ -3799,6 +3710,14 @@
 	return false
 }
 
+func (m *Module) Dylib() bool {
+	return false
+}
+
+func (m *Module) Rlib() bool {
+	return false
+}
+
 func GetMakeLinkType(actx android.ModuleContext, c LinkableInterface) string {
 	if c.InVendorOrProduct() {
 		if c.IsLlndk() {
@@ -4030,8 +3949,6 @@
 	return nil
 }
 
-var _ snapshot.RelativeInstallPath = (*Module)(nil)
-
 type moduleType int
 
 const (
diff --git a/cc/genrule.go b/cc/genrule.go
index 23e97d0..559c155 100644
--- a/cc/genrule.go
+++ b/cc/genrule.go
@@ -19,7 +19,6 @@
 
 	"android/soong/android"
 	"android/soong/genrule"
-	"android/soong/snapshot"
 )
 
 func init() {
@@ -97,13 +96,7 @@
 func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
 	// If the build is using a snapshot, the recovery variant under AOSP directories
 	// is not needed.
-	recoverySnapshotVersion := ctx.DeviceConfig().RecoverySnapshotVersion()
-	if recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" &&
-		!snapshot.IsRecoveryProprietaryModule(ctx) {
-		return false
-	} else {
-		return Bool(g.Recovery_available)
-	}
+	return Bool(g.Recovery_available)
 }
 
 func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleContext) []string {
diff --git a/cc/image.go b/cc/image.go
index 50d1b23..76cb09f 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -22,7 +22,6 @@
 	"strings"
 
 	"android/soong/android"
-	"android/soong/snapshot"
 
 	"github.com/google/blueprint/proptools"
 )
@@ -430,9 +429,6 @@
 	var productVariants []string
 
 	boardVndkVersion := mctx.DeviceConfig().VndkVersion()
-	recoverySnapshotVersion := mctx.DeviceConfig().RecoverySnapshotVersion()
-	usingRecoverySnapshot := recoverySnapshotVersion != "current" &&
-		recoverySnapshotVersion != ""
 	needVndkVersionVendorVariantForLlndk := false
 	if boardVndkVersion != "" {
 		boardVndkApiLevel, err := android.ApiLevelFromUser(mctx, boardVndkVersion)
@@ -478,11 +474,7 @@
 		// BOARD_VNDK_VERSION. The other modules are regarded as AOSP, or
 		// PLATFORM_VNDK_VERSION.
 		if m.HasVendorVariant() {
-			if snapshot.IsVendorProprietaryModule(mctx) {
-				vendorVariants = append(vendorVariants, boardVndkVersion)
-			} else {
-				vendorVariants = append(vendorVariants, "")
-			}
+			vendorVariants = append(vendorVariants, "")
 		}
 
 		// product_available modules are available to /product.
@@ -503,8 +495,6 @@
 				"",
 				boardVndkVersion,
 			)
-		} else if snapshot.IsVendorProprietaryModule(mctx) {
-			vendorVariants = append(vendorVariants, boardVndkVersion)
 		} else {
 			vendorVariants = append(vendorVariants, "")
 		}
@@ -548,15 +538,6 @@
 		coreVariantNeeded = false
 	}
 
-	// If using a snapshot, the recovery variant under AOSP directories is not needed,
-	// except for kernel headers, which needs all variants.
-	if !m.KernelHeadersDecorator() &&
-		!m.IsSnapshotPrebuilt() &&
-		usingRecoverySnapshot &&
-		!snapshot.IsRecoveryProprietaryModule(mctx) {
-		recoveryVariantNeeded = false
-	}
-
 	for _, variant := range android.FirstUniqueStrings(vendorVariants) {
 		if variant == "" {
 			m.AppendExtraVariant(VendorVariation)
diff --git a/cc/library.go b/cc/library.go
index 5607632..e840c3e 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -424,126 +424,9 @@
 	*baseLinker
 	*baseInstaller
 
-	collectedSnapshotHeaders android.Paths
-
 	apiListCoverageXmlPath android.ModuleOutPath
 }
 
-func GlobHeadersForSnapshot(ctx android.ModuleContext, paths android.Paths) android.Paths {
-	ret := android.Paths{}
-
-	// Headers in the source tree should be globbed. On the contrast, generated headers
-	// can't be globbed, and they should be manually collected.
-	// So, we first filter out intermediate directories (which contains generated headers)
-	// from exported directories, and then glob headers under remaining directories.
-	for _, path := range paths {
-		dir := path.String()
-		// Skip if dir is for generated headers
-		if strings.HasPrefix(dir, ctx.Config().OutDir()) {
-			continue
-		}
-
-		// libeigen wrongly exports the root directory "external/eigen". But only two
-		// subdirectories "Eigen" and "unsupported" contain exported header files. Even worse
-		// some of them have no extension. So we need special treatment for libeigen in order
-		// to glob correctly.
-		if dir == "external/eigen" {
-			// Only these two directories contains exported headers.
-			for _, subdir := range []string{"Eigen", "unsupported/Eigen"} {
-				globDir := "external/eigen/" + subdir + "/**/*"
-				glob, err := ctx.GlobWithDeps(globDir, nil)
-				if err != nil {
-					ctx.ModuleErrorf("glob of %q failed: %s", globDir, err)
-					return nil
-				}
-				for _, header := range glob {
-					if strings.HasSuffix(header, "/") {
-						continue
-					}
-					ext := filepath.Ext(header)
-					if ext != "" && ext != ".h" {
-						continue
-					}
-					ret = append(ret, android.PathForSource(ctx, header))
-				}
-			}
-			continue
-		}
-		globDir := dir + "/**/*"
-		glob, err := ctx.GlobWithDeps(globDir, nil)
-		if err != nil {
-			ctx.ModuleErrorf("glob of %q failed: %s", globDir, err)
-			return nil
-		}
-		isLibcxx := strings.HasPrefix(dir, "external/libcxx/include")
-		for _, header := range glob {
-			if isLibcxx {
-				// Glob all files under this special directory, because of C++ headers with no
-				// extension.
-				if strings.HasSuffix(header, "/") {
-					continue
-				}
-			} else {
-				// Filter out only the files with extensions that are headers.
-				found := false
-				for _, ext := range HeaderExts {
-					if strings.HasSuffix(header, ext) {
-						found = true
-						break
-					}
-				}
-				if !found {
-					continue
-				}
-			}
-			ret = append(ret, android.PathForSource(ctx, header))
-		}
-	}
-	return ret
-}
-
-func GlobGeneratedHeadersForSnapshot(_ android.ModuleContext, paths android.Paths) android.Paths {
-	ret := android.Paths{}
-	for _, header := range paths {
-		// TODO(b/148123511): remove exportedDeps after cleaning up genrule
-		if strings.HasSuffix(header.Base(), "-phony") {
-			continue
-		}
-		ret = append(ret, header)
-	}
-	return ret
-}
-
-// collectHeadersForSnapshot collects all exported headers from library.
-// It globs header files in the source tree for exported include directories,
-// and tracks generated header files separately.
-//
-// This is to be called from GenerateAndroidBuildActions, and then collected
-// header files can be retrieved by snapshotHeaders().
-func (l *libraryDecorator) collectHeadersForSnapshot(ctx android.ModuleContext) {
-	ret := android.Paths{}
-
-	// Headers in the source tree should be globbed. On the contrast, generated headers
-	// can't be globbed, and they should be manually collected.
-	// So, we first filter out intermediate directories (which contains generated headers)
-	// from exported directories, and then glob headers under remaining directories.
-	ret = append(ret, GlobHeadersForSnapshot(ctx, append(android.CopyOfPaths(l.flagExporter.dirs), l.flagExporter.systemDirs...))...)
-
-	// Collect generated headers
-	ret = append(ret, GlobGeneratedHeadersForSnapshot(ctx, append(android.CopyOfPaths(l.flagExporter.headers), l.flagExporter.deps...))...)
-
-	l.collectedSnapshotHeaders = ret
-}
-
-// This returns all exported header files, both generated ones and headers from source tree.
-// collectHeadersForSnapshot() must be called before calling this.
-func (l *libraryDecorator) snapshotHeaders() android.Paths {
-	if l.collectedSnapshotHeaders == nil {
-		panic("snapshotHeaders() must be called after collectHeadersForSnapshot()")
-	}
-	return l.collectedSnapshotHeaders
-}
-
 // linkerProps returns the list of properties structs relevant for this library. (For example, if
 // the library is cc_shared_library, then static-library properties are omitted.)
 func (library *libraryDecorator) linkerProps() []interface{} {
diff --git a/cc/linkable.go b/cc/linkable.go
index 6f22091..10cc38f 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -3,7 +3,6 @@
 import (
 	"android/soong/android"
 	"android/soong/fuzz"
-	"android/soong/snapshot"
 
 	"github.com/google/blueprint"
 )
@@ -63,55 +62,9 @@
 // implementation should handle tags from both.
 type SantizableDependencyTagChecker func(tag blueprint.DependencyTag) bool
 
-// Snapshottable defines those functions necessary for handling module snapshots.
-type Snapshottable interface {
-	snapshot.VendorSnapshotModuleInterface
-	snapshot.RecoverySnapshotModuleInterface
-
-	// SnapshotHeaders returns a list of header paths provided by this module.
-	SnapshotHeaders() android.Paths
-
-	// SnapshotLibrary returns true if this module is a snapshot library.
-	IsSnapshotLibrary() bool
-
-	// EffectiveLicenseFiles returns the list of License files for this module.
-	EffectiveLicenseFiles() android.Paths
-
-	// SnapshotRuntimeLibs returns a list of libraries needed by this module at runtime but which aren't build dependencies.
-	SnapshotRuntimeLibs() []string
-
-	// SnapshotSharedLibs returns the list of shared library dependencies for this module.
-	SnapshotSharedLibs() []string
-
-	// SnapshotStaticLibs returns the list of static library dependencies for this module.
-	SnapshotStaticLibs() []string
-
-	// SnapshotDylibs returns the list of dylib library dependencies for this module.
-	SnapshotDylibs() []string
-
-	// SnapshotRlibs returns the list of rlib library dependencies for this module.
-	SnapshotRlibs() []string
-
-	// IsSnapshotPrebuilt returns true if this module is a snapshot prebuilt.
-	IsSnapshotPrebuilt() bool
-
-	// IsSnapshotSanitizer returns true if this snapshot module implements SnapshotSanitizer.
-	IsSnapshotSanitizer() bool
-
-	// IsSnapshotSanitizerAvailable returns true if this snapshot module has a sanitizer source available (cfi, hwasan).
-	IsSnapshotSanitizerAvailable(t SanitizerType) bool
-
-	// SetSnapshotSanitizerVariation sets the sanitizer variation type for this snapshot module.
-	SetSnapshotSanitizerVariation(t SanitizerType, enabled bool)
-
-	// IsSnapshotUnsanitizedVariant returns true if this is the unsanitized snapshot module variant.
-	IsSnapshotUnsanitizedVariant() bool
-}
-
 // LinkableInterface is an interface for a type of module that is linkable in a C++ library.
 type LinkableInterface interface {
 	android.Module
-	Snapshottable
 
 	Module() android.Module
 	CcLibrary() bool
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index c307410..9e727a1 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -14,6 +14,11 @@
 
 package cc
 
+import (
+	"android/soong/android"
+	"strings"
+)
+
 var (
 	llndkLibrarySuffix = ".llndk"
 	llndkHeadersSuffix = ".llndk"
@@ -55,3 +60,21 @@
 	// llndk.symbol_file.
 	Llndk_headers *bool
 }
+
+func makeLlndkVars(ctx android.MakeVarsContext) {
+	// Make uses LLNDK_MOVED_TO_APEX_LIBRARIES to avoid installing libraries on /system if
+	// they been moved to an apex.
+	movedToApexLlndkLibraries := make(map[string]bool)
+	ctx.VisitAllModules(func(module android.Module) {
+		if library := moduleLibraryInterface(module); library != nil && library.hasLLNDKStubs() {
+			// Skip bionic libs, they are handled in different manner
+			name := library.implementationModuleName(module.(*Module).BaseModuleName())
+			if module.(android.ApexModule).DirectlyInAnyApex() && !isBionic(name) {
+				movedToApexLlndkLibraries[name] = true
+			}
+		}
+	})
+
+	ctx.Strict("LLNDK_MOVED_TO_APEX_LIBRARIES",
+		strings.Join(android.SortedKeys(movedToApexLlndkLibraries), " "))
+}
diff --git a/cc/makevars.go b/cc/makevars.go
index 70fdd57..4630330 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -98,7 +98,6 @@
 	ctx.Strict("GLOBAL_CLANG_EXTERNAL_CFLAGS_NO_OVERRIDE", "${config.NoOverrideExternalGlobalCflags}")
 
 	ctx.Strict("BOARD_VNDK_VERSION", ctx.DeviceConfig().VndkVersion())
-	ctx.Strict("RECOVERY_SNAPSHOT_VERSION", ctx.DeviceConfig().RecoverySnapshotVersion())
 
 	// Filter vendor_public_library that are exported to make
 	exportedVendorPublicLibraries := []string{}
@@ -123,12 +122,12 @@
 	ctx.Strict("SOONG_MODULES_USING_WNO_ERROR", makeStringOfKeys(ctx, modulesUsingWnoErrorKey))
 	ctx.Strict("SOONG_MODULES_MISSING_PGO_PROFILE_FILE", makeStringOfKeys(ctx, modulesMissingProfileFileKey))
 
- 	ctx.Strict("CLANG_COVERAGE_CONFIG_CFLAGS", strings.Join(clangCoverageCFlags, " "))
- 	ctx.Strict("CLANG_COVERAGE_CONFIG_COMMFLAGS", strings.Join(clangCoverageCommonFlags, " "))
- 	ctx.Strict("CLANG_COVERAGE_HOST_LDFLAGS", strings.Join(clangCoverageHostLdFlags, " "))
- 	ctx.Strict("CLANG_COVERAGE_INSTR_PROFILE", profileInstrFlag)
- 	ctx.Strict("CLANG_COVERAGE_CONTINUOUS_FLAGS", strings.Join(clangContinuousCoverageFlags, " "))
- 	ctx.Strict("CLANG_COVERAGE_HWASAN_FLAGS", strings.Join(clangCoverageHWASanFlags, " "))
+	ctx.Strict("CLANG_COVERAGE_CONFIG_CFLAGS", strings.Join(clangCoverageCFlags, " "))
+	ctx.Strict("CLANG_COVERAGE_CONFIG_COMMFLAGS", strings.Join(clangCoverageCommonFlags, " "))
+	ctx.Strict("CLANG_COVERAGE_HOST_LDFLAGS", strings.Join(clangCoverageHostLdFlags, " "))
+	ctx.Strict("CLANG_COVERAGE_INSTR_PROFILE", profileInstrFlag)
+	ctx.Strict("CLANG_COVERAGE_CONTINUOUS_FLAGS", strings.Join(clangContinuousCoverageFlags, " "))
+	ctx.Strict("CLANG_COVERAGE_HWASAN_FLAGS", strings.Join(clangCoverageHWASanFlags, " "))
 
 	ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", strings.Join(asanCflags, " "))
 	ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", strings.Join(asanLdflags, " "))
@@ -184,6 +183,8 @@
 	if len(deviceTargets) > 1 {
 		makeVarsToolchain(ctx, "2ND_", deviceTargets[1])
 	}
+
+	makeLlndkVars(ctx)
 }
 
 func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 52b5be9..a2c9c58 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -25,7 +25,6 @@
 
 	"android/soong/android"
 	"android/soong/cc/config"
-	"android/soong/snapshot"
 )
 
 var (
@@ -1141,42 +1140,6 @@
 	return IsSanitizableDependencyTag
 }
 
-// Determines if the current module is a static library going to be captured
-// as vendor snapshot. Such modules must create both cfi and non-cfi variants,
-// except for ones which explicitly disable cfi.
-func needsCfiForVendorSnapshot(mctx android.BaseModuleContext) bool {
-	if inList("hwaddress", mctx.Config().SanitizeDevice()) {
-		// cfi will not be built if SANITIZE_TARGET=hwaddress is set
-		return false
-	}
-
-	if snapshot.IsVendorProprietaryModule(mctx) {
-		return false
-	}
-
-	c := mctx.Module().(PlatformSanitizeable)
-
-	if !c.InVendor() {
-		return false
-	}
-
-	if !c.StaticallyLinked() {
-		return false
-	}
-
-	if c.IsPrebuilt() {
-		return false
-	}
-
-	if !c.SanitizerSupported(cfi) {
-		return false
-	}
-
-	return c.SanitizePropDefined() &&
-		!c.SanitizeNever() &&
-		!c.IsSanitizerExplicitlyDisabled(cfi)
-}
-
 type sanitizerSplitMutator struct {
 	sanitizer SanitizerType
 }
@@ -1201,10 +1164,6 @@
 
 func (s *sanitizerSplitMutator) Split(ctx android.BaseModuleContext) []string {
 	if c, ok := ctx.Module().(PlatformSanitizeable); ok && c.SanitizePropDefined() {
-		if s.sanitizer == cfi && needsCfiForVendorSnapshot(ctx) {
-			return []string{"", s.sanitizer.variationName()}
-		}
-
 		// If the given sanitizer is not requested in the .bp file for a module, it
 		// won't automatically build the sanitized variation.
 		if !c.IsSanitizerEnabled(s.sanitizer) {
@@ -1242,17 +1201,6 @@
 		}
 	}
 
-	if c, ok := ctx.Module().(LinkableInterface); ok {
-		// Check if it's a snapshot module supporting sanitizer
-		if c.IsSnapshotSanitizer() {
-			if c.IsSnapshotSanitizerAvailable(s.sanitizer) {
-				return []string{"", s.sanitizer.variationName()}
-			} else {
-				return []string{""}
-			}
-		}
-	}
-
 	return []string{""}
 }
 
@@ -1277,12 +1225,6 @@
 
 func (s *sanitizerSplitMutator) IncomingTransition(ctx android.IncomingTransitionContext, incomingVariation string) string {
 	if d, ok := ctx.Module().(PlatformSanitizeable); ok {
-		if dm, ok := ctx.Module().(LinkableInterface); ok {
-			if dm.IsSnapshotSanitizerAvailable(s.sanitizer) {
-				return incomingVariation
-			}
-		}
-
 		if !d.SanitizePropDefined() ||
 			d.SanitizeNever() ||
 			d.IsSanitizerExplicitlyDisabled(s.sanitizer) ||
@@ -1393,59 +1335,9 @@
 		if sanitizerVariation {
 			sanitizeable.AddSanitizerDependencies(mctx, s.sanitizer.name())
 		}
-	} else if c, ok := mctx.Module().(LinkableInterface); ok {
-		if c.IsSnapshotSanitizerAvailable(s.sanitizer) {
-			if !c.IsSnapshotUnsanitizedVariant() {
-				// Snapshot sanitizer may have only one variantion.
-				// Skip exporting the module if it already has a sanitizer variation.
-				c.SetPreventInstall()
-				c.SetHideFromMake()
-				return
-			}
-			c.SetSnapshotSanitizerVariation(s.sanitizer, sanitizerVariation)
-
-			// Export the static lib name to make
-			if c.Static() && c.ExportedToMake() {
-				// use BaseModuleName which is the name for Make.
-				if s.sanitizer == cfi {
-					cfiStaticLibs(mctx.Config()).add(c, c.BaseModuleName())
-				} else if s.sanitizer == Hwasan {
-					hwasanStaticLibs(mctx.Config()).add(c, c.BaseModuleName())
-				}
-			}
-		}
 	}
 }
 
-func (c *Module) IsSnapshotSanitizer() bool {
-	if _, ok := c.linker.(SnapshotSanitizer); ok {
-		return true
-	}
-	return false
-}
-
-func (c *Module) IsSnapshotSanitizerAvailable(t SanitizerType) bool {
-	if ss, ok := c.linker.(SnapshotSanitizer); ok {
-		return ss.IsSanitizerAvailable(t)
-	}
-	return false
-}
-
-func (c *Module) SetSnapshotSanitizerVariation(t SanitizerType, enabled bool) {
-	if ss, ok := c.linker.(SnapshotSanitizer); ok {
-		ss.SetSanitizerVariation(t, enabled)
-	} else {
-		panic(fmt.Errorf("Calling SetSnapshotSanitizerVariation on a non-snapshotLibraryDecorator: %s", c.Name()))
-	}
-}
-
-func (c *Module) IsSnapshotUnsanitizedVariant() bool {
-	if ss, ok := c.linker.(SnapshotSanitizer); ok {
-		return ss.IsUnsanitizedVariant()
-	}
-	return false
-}
-
 func (c *Module) SanitizeNever() bool {
 	return Bool(c.sanitize.Properties.SanitizeMutated.Never)
 }
@@ -1492,15 +1384,6 @@
 				return true
 			}
 
-			if p, ok := d.linker.(*snapshotLibraryDecorator); ok {
-				if Bool(p.properties.Sanitize_minimal_dep) {
-					c.sanitize.Properties.MinimalRuntimeDep = true
-				}
-				if Bool(p.properties.Sanitize_ubsan_dep) {
-					c.sanitize.Properties.UbsanRuntimeDep = true
-				}
-			}
-
 			return false
 		})
 	}
@@ -1626,12 +1509,6 @@
 		}
 
 		addStaticDeps := func(dep string, hideSymbols bool) {
-			// If we're using snapshots, redirect to snapshot whenever possible
-			snapshot, _ := android.ModuleProvider(mctx, SnapshotInfoProvider)
-			if lib, ok := snapshot.StaticLibs[dep]; ok {
-				dep = lib
-			}
-
 			// static executable gets static runtime libs
 			depTag := libraryDependencyTag{Kind: staticLibraryDependency, unexportedSymbols: hideSymbols}
 			variations := append(mctx.Target().Variations(),
@@ -1713,12 +1590,6 @@
 				// the best.
 				addStaticDeps(runtimeSharedLibrary, true)
 			} else if !c.static() && !c.Header() {
-				// If we're using snapshots, redirect to snapshot whenever possible
-				snapshot, _ := android.ModuleProvider(mctx, SnapshotInfoProvider)
-				if lib, ok := snapshot.SharedLibs[runtimeSharedLibrary]; ok {
-					runtimeSharedLibrary = lib
-				}
-
 				// Skip apex dependency check for sharedLibraryDependency
 				// when sanitizer diags are enabled. Skipping the check will allow
 				// building with diag libraries without having to list the
diff --git a/cc/sdk.go b/cc/sdk.go
index 6341926..736a958 100644
--- a/cc/sdk.go
+++ b/cc/sdk.go
@@ -106,8 +106,6 @@
 			}
 			ctx.AliasVariation("")
 		}
-	case *snapshotModule:
-		ctx.CreateVariations("")
 	case *CcApiVariant:
 		ccApiVariant, _ := ctx.Module().(*CcApiVariant)
 		if String(ccApiVariant.properties.Variant) == "ndk" {
diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go
index 7d003a9..f4a3d88 100644
--- a/cc/snapshot_prebuilt.go
+++ b/cc/snapshot_prebuilt.go
@@ -18,818 +18,9 @@
 // snapshot mutators and snapshot information maps which are also defined in this file.
 
 import (
-	"fmt"
-	"strings"
-
 	"android/soong/android"
-	"android/soong/snapshot"
-
-	"github.com/google/blueprint"
 )
 
-// This interface overrides snapshot.SnapshotImage to implement cc module specific functions
-type SnapshotImage interface {
-	snapshot.SnapshotImage
-
-	// The image variant name for this snapshot image.
-	// For example, recovery snapshot image will return "recovery", and vendor snapshot image will
-	// return "vendor." + version.
-	imageVariantName(cfg android.DeviceConfig) string
-
-	// The variant suffix for snapshot modules. For example, vendor snapshot modules will have
-	// ".vendor" as their suffix.
-	moduleNameSuffix() string
-}
-
-type vendorSnapshotImage struct {
-	*snapshot.VendorSnapshotImage
-}
-
-type recoverySnapshotImage struct {
-	*snapshot.RecoverySnapshotImage
-}
-
-func (vendorSnapshotImage) imageVariantName(cfg android.DeviceConfig) string {
-	return VendorVariationPrefix + cfg.VndkVersion()
-}
-
-func (vendorSnapshotImage) moduleNameSuffix() string {
-	return VendorSuffix
-}
-
-func (recoverySnapshotImage) imageVariantName(cfg android.DeviceConfig) string {
-	return android.RecoveryVariation
-}
-
-func (recoverySnapshotImage) moduleNameSuffix() string {
-	return RecoverySuffix
-}
-
-// Override existing vendor and recovery snapshot for cc module specific extra functions
-var VendorSnapshotImageSingleton vendorSnapshotImage = vendorSnapshotImage{&snapshot.VendorSnapshotImageSingleton}
-var RecoverySnapshotImageSingleton recoverySnapshotImage = recoverySnapshotImage{&snapshot.RecoverySnapshotImageSingleton}
-
-func RegisterVendorSnapshotModules(ctx android.RegistrationContext) {
-	ctx.RegisterModuleType("vendor_snapshot", vendorSnapshotFactory)
-	ctx.RegisterModuleType("vendor_snapshot_shared", VendorSnapshotSharedFactory)
-	ctx.RegisterModuleType("vendor_snapshot_static", VendorSnapshotStaticFactory)
-	ctx.RegisterModuleType("vendor_snapshot_header", VendorSnapshotHeaderFactory)
-	ctx.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
-	ctx.RegisterModuleType("vendor_snapshot_object", VendorSnapshotObjectFactory)
-}
-
-func RegisterRecoverySnapshotModules(ctx android.RegistrationContext) {
-	ctx.RegisterModuleType("recovery_snapshot", recoverySnapshotFactory)
-	ctx.RegisterModuleType("recovery_snapshot_shared", RecoverySnapshotSharedFactory)
-	ctx.RegisterModuleType("recovery_snapshot_static", RecoverySnapshotStaticFactory)
-	ctx.RegisterModuleType("recovery_snapshot_header", RecoverySnapshotHeaderFactory)
-	ctx.RegisterModuleType("recovery_snapshot_binary", RecoverySnapshotBinaryFactory)
-	ctx.RegisterModuleType("recovery_snapshot_object", RecoverySnapshotObjectFactory)
-}
-
-func init() {
-	RegisterVendorSnapshotModules(android.InitRegistrationContext)
-	RegisterRecoverySnapshotModules(android.InitRegistrationContext)
-	android.RegisterMakeVarsProvider(pctx, snapshotMakeVarsProvider)
-}
-
-const (
-	snapshotHeaderSuffix = "_header."
-	SnapshotSharedSuffix = "_shared."
-	SnapshotStaticSuffix = "_static."
-	snapshotBinarySuffix = "_binary."
-	snapshotObjectSuffix = "_object."
-	SnapshotRlibSuffix   = "_rlib."
-	SnapshotDylibSuffix  = "_dylib."
-)
-
-type SnapshotProperties struct {
-	Header_libs []string `android:"arch_variant"`
-	Static_libs []string `android:"arch_variant"`
-	Shared_libs []string `android:"arch_variant"`
-	Rlibs       []string `android:"arch_variant"`
-	Dylibs      []string `android:"arch_variant"`
-	Vndk_libs   []string `android:"arch_variant"`
-	Binaries    []string `android:"arch_variant"`
-	Objects     []string `android:"arch_variant"`
-}
-type snapshotModule struct {
-	android.ModuleBase
-
-	properties SnapshotProperties
-
-	baseSnapshot BaseSnapshotDecorator
-
-	image SnapshotImage
-}
-
-func (s *snapshotModule) ImageMutatorBegin(ctx android.BaseModuleContext) {
-	cfg := ctx.DeviceConfig()
-	if !s.image.IsUsingSnapshot(cfg) || s.image.TargetSnapshotVersion(cfg) != s.baseSnapshot.Version() {
-		s.Disable()
-	}
-}
-
-func (s *snapshotModule) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
-	return false
-}
-
-func (s *snapshotModule) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
-	return false
-}
-
-func (s *snapshotModule) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
-	return false
-}
-
-func (s *snapshotModule) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
-	return false
-}
-
-func (s *snapshotModule) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
-	return false
-}
-
-func (s *snapshotModule) ExtraImageVariations(ctx android.BaseModuleContext) []string {
-	return []string{s.image.imageVariantName(ctx.DeviceConfig())}
-}
-
-func (s *snapshotModule) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
-}
-
-func (s *snapshotModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
-	// Nothing, the snapshot module is only used to forward dependency information in DepsMutator.
-}
-
-func getSnapshotNameSuffix(moduleSuffix, version, arch string) string {
-	versionSuffix := version
-	if arch != "" {
-		versionSuffix += "." + arch
-	}
-	return moduleSuffix + versionSuffix
-}
-
-func (s *snapshotModule) DepsMutator(ctx android.BottomUpMutatorContext) {
-	collectSnapshotMap := func(names []string, snapshotSuffix, moduleSuffix string) map[string]string {
-		snapshotMap := make(map[string]string)
-		for _, name := range names {
-			snapshotMap[name] = name +
-				getSnapshotNameSuffix(snapshotSuffix+moduleSuffix,
-					s.baseSnapshot.Version(),
-					ctx.DeviceConfig().Arches()[0].ArchType.String())
-		}
-		return snapshotMap
-	}
-
-	snapshotSuffix := s.image.moduleNameSuffix()
-	headers := collectSnapshotMap(s.properties.Header_libs, snapshotSuffix, snapshotHeaderSuffix)
-	binaries := collectSnapshotMap(s.properties.Binaries, snapshotSuffix, snapshotBinarySuffix)
-	objects := collectSnapshotMap(s.properties.Objects, snapshotSuffix, snapshotObjectSuffix)
-	staticLibs := collectSnapshotMap(s.properties.Static_libs, snapshotSuffix, SnapshotStaticSuffix)
-	sharedLibs := collectSnapshotMap(s.properties.Shared_libs, snapshotSuffix, SnapshotSharedSuffix)
-	rlibs := collectSnapshotMap(s.properties.Rlibs, snapshotSuffix, SnapshotRlibSuffix)
-	dylibs := collectSnapshotMap(s.properties.Dylibs, snapshotSuffix, SnapshotDylibSuffix)
-	vndkLibs := collectSnapshotMap(s.properties.Vndk_libs, "", vndkSuffix)
-	for k, v := range vndkLibs {
-		sharedLibs[k] = v
-	}
-
-	android.SetProvider(ctx, SnapshotInfoProvider, SnapshotInfo{
-		HeaderLibs: headers,
-		Binaries:   binaries,
-		Objects:    objects,
-		StaticLibs: staticLibs,
-		SharedLibs: sharedLibs,
-		Rlibs:      rlibs,
-		Dylibs:     dylibs,
-	})
-}
-
-type SnapshotInfo struct {
-	HeaderLibs, Binaries, Objects, StaticLibs, SharedLibs, Rlibs, Dylibs map[string]string
-}
-
-var SnapshotInfoProvider = blueprint.NewMutatorProvider[SnapshotInfo]("deps")
-
-var _ android.ImageInterface = (*snapshotModule)(nil)
-
-func snapshotMakeVarsProvider(ctx android.MakeVarsContext) {
-	snapshotSet := map[string]struct{}{}
-	ctx.VisitAllModules(func(m android.Module) {
-		if s, ok := m.(*snapshotModule); ok {
-			if _, ok := snapshotSet[s.Name()]; ok {
-				// arch variant generates duplicated modules
-				// skip this as we only need to know the path of the module.
-				return
-			}
-			snapshotSet[s.Name()] = struct{}{}
-			imageNameVersion := strings.Split(s.image.imageVariantName(ctx.DeviceConfig()), ".")
-			ctx.Strict(
-				strings.Join([]string{strings.ToUpper(imageNameVersion[0]), s.baseSnapshot.Version(), "SNAPSHOT_DIR"}, "_"),
-				ctx.ModuleDir(s))
-		}
-	})
-}
-
-func vendorSnapshotFactory() android.Module {
-	return snapshotFactory(VendorSnapshotImageSingleton)
-}
-
-func recoverySnapshotFactory() android.Module {
-	return snapshotFactory(RecoverySnapshotImageSingleton)
-}
-
-func snapshotFactory(image SnapshotImage) android.Module {
-	snapshotModule := &snapshotModule{}
-	snapshotModule.image = image
-	snapshotModule.AddProperties(
-		&snapshotModule.properties,
-		&snapshotModule.baseSnapshot.baseProperties)
-	android.InitAndroidArchModule(snapshotModule, android.DeviceSupported, android.MultilibBoth)
-	return snapshotModule
-}
-
-type BaseSnapshotDecoratorProperties struct {
-	// snapshot version.
-	Version string
-
-	// Target arch name of the snapshot (e.g. 'arm64' for variant 'aosp_arm64')
-	Target_arch string
-
-	// Suffix to be added to the module name when exporting to Android.mk, e.g. ".vendor".
-	Androidmk_suffix string `blueprint:"mutated"`
-
-	// Suffix to be added to the module name, e.g., vendor_shared,
-	// recovery_shared, etc.
-	ModuleSuffix string `blueprint:"mutated"`
-}
-
-// BaseSnapshotDecorator provides common basic functions for all snapshot modules, such as snapshot
-// version, snapshot arch, etc. It also adds a special suffix to Soong module name, so it doesn't
-// collide with source modules. e.g. the following example module,
-//
-//	vendor_snapshot_static {
-//	    name: "libbase",
-//	    arch: "arm64",
-//	    version: 30,
-//	    ...
-//	}
-//
-// will be seen as "libbase.vendor_static.30.arm64" by Soong.
-type BaseSnapshotDecorator struct {
-	baseProperties BaseSnapshotDecoratorProperties
-	Image          SnapshotImage
-}
-
-func (p *BaseSnapshotDecorator) Name(name string) string {
-	return name + p.NameSuffix()
-}
-
-func (p *BaseSnapshotDecorator) NameSuffix() string {
-	return getSnapshotNameSuffix(p.moduleSuffix(), p.Version(), p.Arch())
-}
-
-func (p *BaseSnapshotDecorator) Version() string {
-	return p.baseProperties.Version
-}
-
-func (p *BaseSnapshotDecorator) Arch() string {
-	return p.baseProperties.Target_arch
-}
-
-func (p *BaseSnapshotDecorator) moduleSuffix() string {
-	return p.baseProperties.ModuleSuffix
-}
-
-func (p *BaseSnapshotDecorator) IsSnapshotPrebuilt() bool {
-	return true
-}
-
-func (p *BaseSnapshotDecorator) SnapshotAndroidMkSuffix() string {
-	return p.baseProperties.Androidmk_suffix
-}
-
-func (p *BaseSnapshotDecorator) SetSnapshotAndroidMkSuffix(ctx android.ModuleContext, variant string) {
-	// If there are any 2 or more variations among {core, product, vendor, recovery}
-	// we have to add the androidmk suffix to avoid duplicate modules with the same
-	// name.
-	variations := append(ctx.Target().Variations(), blueprint.Variation{
-		Mutator:   "image",
-		Variation: android.CoreVariation})
-
-	if ctx.OtherModuleFarDependencyVariantExists(variations, ctx.Module().(LinkableInterface).BaseModuleName()) {
-		p.baseProperties.Androidmk_suffix = p.Image.moduleNameSuffix()
-		return
-	}
-
-	variations = append(ctx.Target().Variations(), blueprint.Variation{
-		Mutator:   "image",
-		Variation: ProductVariation})
-
-	if ctx.OtherModuleFarDependencyVariantExists(variations, ctx.Module().(LinkableInterface).BaseModuleName()) {
-		p.baseProperties.Androidmk_suffix = p.Image.moduleNameSuffix()
-		return
-	}
-
-	images := []SnapshotImage{VendorSnapshotImageSingleton, RecoverySnapshotImageSingleton}
-
-	for _, image := range images {
-		if p.Image == image {
-			continue
-		}
-		variations = append(ctx.Target().Variations(), blueprint.Variation{
-			Mutator:   "image",
-			Variation: image.imageVariantName(ctx.DeviceConfig())})
-
-		if ctx.OtherModuleFarDependencyVariantExists(variations,
-			ctx.Module().(LinkableInterface).BaseModuleName()+
-				getSnapshotNameSuffix(
-					image.moduleNameSuffix()+variant,
-					p.Version(),
-					ctx.DeviceConfig().Arches()[0].ArchType.String())) {
-			p.baseProperties.Androidmk_suffix = p.Image.moduleNameSuffix()
-			return
-		}
-	}
-
-	p.baseProperties.Androidmk_suffix = ""
-}
-
-// Call this with a module suffix after creating a snapshot module, such as
-// vendorSnapshotSharedSuffix, recoverySnapshotBinarySuffix, etc.
-func (p *BaseSnapshotDecorator) Init(m LinkableInterface, image SnapshotImage, moduleSuffix string) {
-	p.Image = image
-	p.baseProperties.ModuleSuffix = image.moduleNameSuffix() + moduleSuffix
-	m.AddProperties(&p.baseProperties)
-	android.AddLoadHook(m, func(ctx android.LoadHookContext) {
-		vendorSnapshotLoadHook(ctx, p)
-	})
-}
-
-// vendorSnapshotLoadHook disables snapshots if it's not BOARD_VNDK_VERSION.
-// As vendor snapshot is only for vendor, such modules won't be used at all.
-func vendorSnapshotLoadHook(ctx android.LoadHookContext, p *BaseSnapshotDecorator) {
-	if p.Version() != ctx.DeviceConfig().VndkVersion() {
-		ctx.Module().Disable()
-		return
-	}
-}
-
-// Module definitions for snapshots of libraries (shared, static, header).
-//
-// Modules (vendor|recovery)_snapshot_(shared|static|header) are defined here. Shared libraries and
-// static libraries have their prebuilt library files (.so for shared, .a for static) as their src,
-// which can be installed or linked against. Also they export flags needed when linked, such as
-// include directories, c flags, sanitize dependency information, etc.
-//
-// These modules are auto-generated by development/vendor_snapshot/update.py.
-type SnapshotLibraryProperties struct {
-	// Prebuilt file for each arch.
-	Src *string `android:"arch_variant"`
-
-	// list of directories that will be added to the include path (using -I).
-	Export_include_dirs []string `android:"arch_variant"`
-
-	// list of directories that will be added to the system path (using -isystem).
-	Export_system_include_dirs []string `android:"arch_variant"`
-
-	// list of flags that will be used for any module that links against this module.
-	Export_flags []string `android:"arch_variant"`
-
-	// Whether this prebuilt needs to depend on sanitize ubsan runtime or not.
-	Sanitize_ubsan_dep *bool `android:"arch_variant"`
-
-	// Whether this prebuilt needs to depend on sanitize minimal runtime or not.
-	Sanitize_minimal_dep *bool `android:"arch_variant"`
-}
-
-type SnapshotSanitizer interface {
-	IsSanitizerAvailable(t SanitizerType) bool
-	SetSanitizerVariation(t SanitizerType, enabled bool)
-	IsSanitizerEnabled(t SanitizerType) bool
-	IsUnsanitizedVariant() bool
-}
-
-type snapshotLibraryDecorator struct {
-	BaseSnapshotDecorator
-	*libraryDecorator
-	properties          SnapshotLibraryProperties
-	sanitizerProperties struct {
-		SanitizerVariation SanitizerType `blueprint:"mutated"`
-
-		// Library flags for cfi variant.
-		Cfi SnapshotLibraryProperties `android:"arch_variant"`
-
-		// Library flags for hwasan variant.
-		Hwasan SnapshotLibraryProperties `android:"arch_variant"`
-	}
-}
-
-func (p *snapshotLibraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
-	p.libraryDecorator.libName = strings.TrimSuffix(ctx.ModuleName(), p.NameSuffix())
-	return p.libraryDecorator.linkerFlags(ctx, flags)
-}
-
-func (p *snapshotLibraryDecorator) MatchesWithDevice(config android.DeviceConfig) bool {
-	arches := config.Arches()
-	if len(arches) == 0 || arches[0].ArchType.String() != p.Arch() {
-		return false
-	}
-	if !p.header() && p.properties.Src == nil {
-		return false
-	}
-	return true
-}
-
-// cc modules' link functions are to link compiled objects into final binaries.
-// As snapshots are prebuilts, this just returns the prebuilt binary after doing things which are
-// done by normal library decorator, e.g. exporting flags.
-func (p *snapshotLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
-	var variant string
-	if p.shared() {
-		variant = SnapshotSharedSuffix
-	} else if p.static() {
-		variant = SnapshotStaticSuffix
-	} else {
-		variant = snapshotHeaderSuffix
-	}
-
-	p.SetSnapshotAndroidMkSuffix(ctx, variant)
-
-	if p.header() {
-		return p.libraryDecorator.link(ctx, flags, deps, objs)
-	}
-
-	if p.IsSanitizerEnabled(cfi) {
-		p.properties = p.sanitizerProperties.Cfi
-	} else if p.IsSanitizerEnabled(Hwasan) {
-		p.properties = p.sanitizerProperties.Hwasan
-	}
-
-	if !p.MatchesWithDevice(ctx.DeviceConfig()) {
-		return nil
-	}
-
-	// Flags specified directly to this module.
-	p.libraryDecorator.reexportDirs(android.PathsForModuleSrc(ctx, p.properties.Export_include_dirs)...)
-	p.libraryDecorator.reexportSystemDirs(android.PathsForModuleSrc(ctx, p.properties.Export_system_include_dirs)...)
-	p.libraryDecorator.reexportFlags(p.properties.Export_flags...)
-
-	// Flags reexported from dependencies. (e.g. vndk_prebuilt_shared)
-	p.libraryDecorator.reexportDirs(deps.ReexportedDirs...)
-	p.libraryDecorator.reexportSystemDirs(deps.ReexportedSystemDirs...)
-	p.libraryDecorator.reexportFlags(deps.ReexportedFlags...)
-	p.libraryDecorator.reexportDeps(deps.ReexportedDeps...)
-	p.libraryDecorator.addExportedGeneratedHeaders(deps.ReexportedGeneratedHeaders...)
-
-	in := android.PathForModuleSrc(ctx, *p.properties.Src)
-	p.unstrippedOutputFile = in
-
-	if p.shared() {
-		libName := in.Base()
-
-		// Optimize out relinking against shared libraries whose interface hasn't changed by
-		// depending on a table of contents file instead of the library itself.
-		tocFile := android.PathForModuleOut(ctx, libName+".toc")
-		p.tocFile = android.OptionalPathForPath(tocFile)
-		TransformSharedObjectToToc(ctx, in, tocFile)
-
-		android.SetProvider(ctx, SharedLibraryInfoProvider, SharedLibraryInfo{
-			SharedLibrary: in,
-			Target:        ctx.Target(),
-
-			TableOfContents: p.tocFile,
-		})
-	}
-
-	if p.static() {
-		depSet := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL).Direct(in).Build()
-		android.SetProvider(ctx, StaticLibraryInfoProvider, StaticLibraryInfo{
-			StaticLibrary: in,
-
-			TransitiveStaticLibrariesForOrdering: depSet,
-		})
-	}
-
-	p.libraryDecorator.flagExporter.setProvider(ctx)
-
-	return in
-}
-
-func (p *snapshotLibraryDecorator) install(ctx ModuleContext, file android.Path) {
-	if p.MatchesWithDevice(ctx.DeviceConfig()) && p.shared() {
-		p.baseInstaller.install(ctx, file)
-	}
-}
-
-func (p *snapshotLibraryDecorator) nativeCoverage() bool {
-	return false
-}
-
-var _ SnapshotSanitizer = (*snapshotLibraryDecorator)(nil)
-
-func (p *snapshotLibraryDecorator) IsSanitizerAvailable(t SanitizerType) bool {
-	switch t {
-	case cfi:
-		return p.sanitizerProperties.Cfi.Src != nil
-	case Hwasan:
-		return p.sanitizerProperties.Hwasan.Src != nil
-	default:
-		return false
-	}
-}
-
-func (p *snapshotLibraryDecorator) SetSanitizerVariation(t SanitizerType, enabled bool) {
-	if !enabled || p.IsSanitizerEnabled(t) {
-		return
-	}
-	if !p.IsUnsanitizedVariant() {
-		panic(fmt.Errorf("snapshot Sanitizer must be one of Cfi or Hwasan but not both"))
-	}
-	p.sanitizerProperties.SanitizerVariation = t
-}
-
-func (p *snapshotLibraryDecorator) IsSanitizerEnabled(t SanitizerType) bool {
-	return p.sanitizerProperties.SanitizerVariation == t
-}
-
-func (p *snapshotLibraryDecorator) IsUnsanitizedVariant() bool {
-	return !p.IsSanitizerEnabled(Asan) &&
-		!p.IsSanitizerEnabled(Hwasan)
-}
-
-func snapshotLibraryFactory(image SnapshotImage, moduleSuffix string) (*Module, *snapshotLibraryDecorator) {
-	module, library := NewLibrary(android.DeviceSupported)
-
-	module.stl = nil
-	module.sanitize = nil
-	library.disableStripping()
-
-	prebuilt := &snapshotLibraryDecorator{
-		libraryDecorator: library,
-	}
-
-	prebuilt.baseLinker.Properties.No_libcrt = BoolPtr(true)
-	prebuilt.baseLinker.Properties.Nocrt = BoolPtr(true)
-
-	// Prevent default system libs (libc, libm, and libdl) from being linked
-	if prebuilt.baseLinker.Properties.System_shared_libs == nil {
-		prebuilt.baseLinker.Properties.System_shared_libs = []string{}
-	}
-
-	module.compiler = nil
-	module.linker = prebuilt
-	module.installer = prebuilt
-
-	prebuilt.Init(module, image, moduleSuffix)
-	module.AddProperties(
-		&prebuilt.properties,
-		&prebuilt.sanitizerProperties,
-	)
-
-	return module, prebuilt
-}
-
-// vendor_snapshot_shared is a special prebuilt shared library which is auto-generated by
-// development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_shared
-// overrides the vendor variant of the cc shared library with the same name, if BOARD_VNDK_VERSION
-// is set.
-func VendorSnapshotSharedFactory() android.Module {
-	module, prebuilt := snapshotLibraryFactory(VendorSnapshotImageSingleton, SnapshotSharedSuffix)
-	prebuilt.libraryDecorator.BuildOnlyShared()
-	return module.Init()
-}
-
-// recovery_snapshot_shared is a special prebuilt shared library which is auto-generated by
-// development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_shared
-// overrides the recovery variant of the cc shared library with the same name, if BOARD_VNDK_VERSION
-// is set.
-func RecoverySnapshotSharedFactory() android.Module {
-	module, prebuilt := snapshotLibraryFactory(RecoverySnapshotImageSingleton, SnapshotSharedSuffix)
-	prebuilt.libraryDecorator.BuildOnlyShared()
-	return module.Init()
-}
-
-// vendor_snapshot_static is a special prebuilt static library which is auto-generated by
-// development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_static
-// overrides the vendor variant of the cc static library with the same name, if BOARD_VNDK_VERSION
-// is set.
-func VendorSnapshotStaticFactory() android.Module {
-	module, prebuilt := snapshotLibraryFactory(VendorSnapshotImageSingleton, SnapshotStaticSuffix)
-	prebuilt.libraryDecorator.BuildOnlyStatic()
-	return module.Init()
-}
-
-// recovery_snapshot_static is a special prebuilt static library which is auto-generated by
-// development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_static
-// overrides the recovery variant of the cc static library with the same name, if BOARD_VNDK_VERSION
-// is set.
-func RecoverySnapshotStaticFactory() android.Module {
-	module, prebuilt := snapshotLibraryFactory(RecoverySnapshotImageSingleton, SnapshotStaticSuffix)
-	prebuilt.libraryDecorator.BuildOnlyStatic()
-	return module.Init()
-}
-
-// vendor_snapshot_header is a special header library which is auto-generated by
-// development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_header
-// overrides the vendor variant of the cc header library with the same name, if BOARD_VNDK_VERSION
-// is set.
-func VendorSnapshotHeaderFactory() android.Module {
-	module, prebuilt := snapshotLibraryFactory(VendorSnapshotImageSingleton, snapshotHeaderSuffix)
-	prebuilt.libraryDecorator.HeaderOnly()
-	return module.Init()
-}
-
-// recovery_snapshot_header is a special header library which is auto-generated by
-// development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_header
-// overrides the recovery variant of the cc header library with the same name, if BOARD_VNDK_VERSION
-// is set.
-func RecoverySnapshotHeaderFactory() android.Module {
-	module, prebuilt := snapshotLibraryFactory(RecoverySnapshotImageSingleton, snapshotHeaderSuffix)
-	prebuilt.libraryDecorator.HeaderOnly()
-	return module.Init()
-}
-
-// Module definitions for snapshots of executable binaries.
-//
-// Modules (vendor|recovery)_snapshot_binary are defined here. They have their prebuilt executable
-// binaries (e.g. toybox, sh) as their src, which can be installed.
-//
-// These modules are auto-generated by development/vendor_snapshot/update.py.
-type snapshotBinaryProperties struct {
-	// Prebuilt file for each arch.
-	Src *string `android:"arch_variant"`
-}
-
-type snapshotBinaryDecorator struct {
-	BaseSnapshotDecorator
-	*binaryDecorator
-	properties snapshotBinaryProperties
-}
-
-func (p *snapshotBinaryDecorator) MatchesWithDevice(config android.DeviceConfig) bool {
-	if config.DeviceArch() != p.Arch() {
-		return false
-	}
-	if p.properties.Src == nil {
-		return false
-	}
-	return true
-}
-
-// cc modules' link functions are to link compiled objects into final binaries.
-// As snapshots are prebuilts, this just returns the prebuilt binary
-func (p *snapshotBinaryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
-	p.SetSnapshotAndroidMkSuffix(ctx, snapshotBinarySuffix)
-
-	if !p.MatchesWithDevice(ctx.DeviceConfig()) {
-		return nil
-	}
-
-	in := android.PathForModuleSrc(ctx, *p.properties.Src)
-	p.unstrippedOutputFile = in
-	binName := in.Base()
-
-	// use cpExecutable to make it executable
-	outputFile := android.PathForModuleOut(ctx, binName)
-	ctx.Build(pctx, android.BuildParams{
-		Rule:        android.CpExecutable,
-		Description: "prebuilt",
-		Output:      outputFile,
-		Input:       in,
-	})
-
-	// binary snapshots need symlinking
-	p.setSymlinkList(ctx)
-
-	return outputFile
-}
-
-func (p *snapshotBinaryDecorator) nativeCoverage() bool {
-	return false
-}
-
-// vendor_snapshot_binary is a special prebuilt executable binary which is auto-generated by
-// development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_binary
-// overrides the vendor variant of the cc binary with the same name, if BOARD_VNDK_VERSION is set.
-func VendorSnapshotBinaryFactory() android.Module {
-	return snapshotBinaryFactory(VendorSnapshotImageSingleton, snapshotBinarySuffix)
-}
-
-// recovery_snapshot_binary is a special prebuilt executable binary which is auto-generated by
-// development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_binary
-// overrides the recovery variant of the cc binary with the same name, if BOARD_VNDK_VERSION is set.
-func RecoverySnapshotBinaryFactory() android.Module {
-	return snapshotBinaryFactory(RecoverySnapshotImageSingleton, snapshotBinarySuffix)
-}
-
-func snapshotBinaryFactory(image SnapshotImage, moduleSuffix string) android.Module {
-	module, binary := NewBinary(android.DeviceSupported)
-	binary.baseLinker.Properties.No_libcrt = BoolPtr(true)
-	binary.baseLinker.Properties.Nocrt = BoolPtr(true)
-
-	// Prevent default system libs (libc, libm, and libdl) from being linked
-	if binary.baseLinker.Properties.System_shared_libs == nil {
-		binary.baseLinker.Properties.System_shared_libs = []string{}
-	}
-
-	prebuilt := &snapshotBinaryDecorator{
-		binaryDecorator: binary,
-	}
-
-	module.compiler = nil
-	module.sanitize = nil
-	module.stl = nil
-	module.linker = prebuilt
-
-	prebuilt.Init(module, image, moduleSuffix)
-	module.AddProperties(&prebuilt.properties)
-	return module.Init()
-}
-
-// Module definitions for snapshots of object files (*.o).
-//
-// Modules (vendor|recovery)_snapshot_object are defined here. They have their prebuilt object
-// files (*.o) as their src.
-//
-// These modules are auto-generated by development/vendor_snapshot/update.py.
-type vendorSnapshotObjectProperties struct {
-	// Prebuilt file for each arch.
-	Src *string `android:"arch_variant"`
-}
-
-type snapshotObjectLinker struct {
-	BaseSnapshotDecorator
-	objectLinker
-	properties vendorSnapshotObjectProperties
-}
-
-func (p *snapshotObjectLinker) MatchesWithDevice(config android.DeviceConfig) bool {
-	if config.DeviceArch() != p.Arch() {
-		return false
-	}
-	if p.properties.Src == nil {
-		return false
-	}
-	return true
-}
-
-// cc modules' link functions are to link compiled objects into final binaries.
-// As snapshots are prebuilts, this just returns the prebuilt binary
-func (p *snapshotObjectLinker) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
-	p.SetSnapshotAndroidMkSuffix(ctx, snapshotObjectSuffix)
-
-	if !p.MatchesWithDevice(ctx.DeviceConfig()) {
-		return nil
-	}
-
-	return android.PathForModuleSrc(ctx, *p.properties.Src)
-}
-
-func (p *snapshotObjectLinker) nativeCoverage() bool {
-	return false
-}
-
-// vendor_snapshot_object is a special prebuilt compiled object file which is auto-generated by
-// development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_object
-// overrides the vendor variant of the cc object with the same name, if BOARD_VNDK_VERSION is set.
-func VendorSnapshotObjectFactory() android.Module {
-	module := newObject(android.DeviceSupported)
-
-	prebuilt := &snapshotObjectLinker{
-		objectLinker: objectLinker{
-			baseLinker: NewBaseLinker(nil),
-		},
-	}
-	module.linker = prebuilt
-
-	prebuilt.Init(module, VendorSnapshotImageSingleton, snapshotObjectSuffix)
-	module.AddProperties(&prebuilt.properties)
-
-	// vendor_snapshot_object module does not provide sanitizer variants
-	module.sanitize.Properties.Sanitize.Never = BoolPtr(true)
-
-	return module.Init()
-}
-
-// recovery_snapshot_object is a special prebuilt compiled object file which is auto-generated by
-// development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_object
-// overrides the recovery variant of the cc object with the same name, if BOARD_VNDK_VERSION is set.
-func RecoverySnapshotObjectFactory() android.Module {
-	module := newObject(android.DeviceSupported)
-
-	prebuilt := &snapshotObjectLinker{
-		objectLinker: objectLinker{
-			baseLinker: NewBaseLinker(nil),
-		},
-	}
-	module.linker = prebuilt
-
-	prebuilt.Init(module, RecoverySnapshotImageSingleton, snapshotObjectSuffix)
-	module.AddProperties(&prebuilt.properties)
-	return module.Init()
-}
-
 type SnapshotInterface interface {
 	MatchesWithDevice(config android.DeviceConfig) bool
 	IsSnapshotPrebuilt() bool
@@ -838,6 +29,3 @@
 }
 
 var _ SnapshotInterface = (*vndkPrebuiltLibraryDecorator)(nil)
-var _ SnapshotInterface = (*snapshotLibraryDecorator)(nil)
-var _ SnapshotInterface = (*snapshotBinaryDecorator)(nil)
-var _ SnapshotInterface = (*snapshotObjectLinker)(nil)
diff --git a/cc/snapshot_utils.go b/cc/snapshot_utils.go
deleted file mode 100644
index 1ee120e..0000000
--- a/cc/snapshot_utils.go
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright 2020 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//	http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package cc
-
-// This file contains utility types and functions for VNDK / vendor snapshot.
-
-import (
-	"android/soong/android"
-)
-
-var (
-	HeaderExts = []string{".h", ".hh", ".hpp", ".hxx", ".h++", ".inl", ".inc", ".ipp", ".h.generic"}
-)
-
-func (m *Module) IsSnapshotLibrary() bool {
-	if _, ok := m.linker.(snapshotLibraryInterface); ok {
-		return true
-	}
-	return false
-}
-
-func (m *Module) SnapshotHeaders() android.Paths {
-	if m.IsSnapshotLibrary() {
-		return m.linker.(snapshotLibraryInterface).snapshotHeaders()
-	}
-	return android.Paths{}
-}
-
-func (m *Module) Dylib() bool {
-	return false
-}
-
-func (m *Module) Rlib() bool {
-	return false
-}
-
-func (m *Module) SnapshotRuntimeLibs() []string {
-	return m.Properties.SnapshotRuntimeLibs
-}
-
-func (m *Module) SnapshotSharedLibs() []string {
-	return m.Properties.SnapshotSharedLibs
-}
-
-func (m *Module) SnapshotStaticLibs() []string {
-	return m.Properties.SnapshotStaticLibs
-}
-
-func (m *Module) SnapshotRlibs() []string {
-	return []string{}
-}
-
-func (m *Module) SnapshotDylibs() []string {
-	return []string{}
-}
-
-// snapshotLibraryInterface is an interface for libraries captured to VNDK / vendor snapshots.
-type snapshotLibraryInterface interface {
-	libraryInterface
-
-	// collectHeadersForSnapshot is called in GenerateAndroidBuildActions for snapshot aware
-	// modules (See isSnapshotAware below).
-	// This function should gather all headers needed for snapshot.
-	collectHeadersForSnapshot(ctx android.ModuleContext)
-
-	// snapshotHeaders should return collected headers by collectHeadersForSnapshot.
-	// Calling snapshotHeaders before collectHeadersForSnapshot is an error.
-	snapshotHeaders() android.Paths
-}
-
-var _ snapshotLibraryInterface = (*prebuiltLibraryLinker)(nil)
-var _ snapshotLibraryInterface = (*libraryDecorator)(nil)
-
-// snapshotMap is a helper wrapper to a map from base module name to snapshot module name.
-type snapshotMap struct {
-	snapshots map[string]string
-}
-
-func newSnapshotMap() *snapshotMap {
-	return &snapshotMap{
-		snapshots: make(map[string]string),
-	}
-}
-
-func snapshotMapKey(name string, arch android.ArchType) string {
-	return name + ":" + arch.String()
-}
-
-// Adds a snapshot name for given module name and architecture.
-// e.g. add("libbase", X86, "libbase.vndk.29.x86")
-func (s *snapshotMap) add(name string, arch android.ArchType, snapshot string) {
-	s.snapshots[snapshotMapKey(name, arch)] = snapshot
-}
-
-// Returns snapshot name for given module name and architecture, if found.
-// e.g. get("libcutils", X86) => "libcutils.vndk.29.x86", true
-func (s *snapshotMap) get(name string, arch android.ArchType) (snapshot string, found bool) {
-	snapshot, found = s.snapshots[snapshotMapKey(name, arch)]
-	return snapshot, found
-}
-
-// ShouldCollectHeadersForSnapshot determines if the module is a possible candidate for snapshot.
-// If it's true, collectHeadersForSnapshot will be called in GenerateAndroidBuildActions.
-func ShouldCollectHeadersForSnapshot(ctx android.ModuleContext, m LinkableInterface, apexInfo android.ApexInfo) bool {
-	if ctx.DeviceConfig().VndkVersion() != "current" &&
-		ctx.DeviceConfig().RecoverySnapshotVersion() != "current" {
-		return false
-	}
-	if _, ok := isVndkSnapshotAware(ctx.DeviceConfig(), m, apexInfo); ok {
-		return ctx.Config().VndkSnapshotBuildArtifacts()
-	}
-
-	for _, image := range []SnapshotImage{VendorSnapshotImageSingleton, RecoverySnapshotImageSingleton} {
-		if isSnapshotAware(ctx.DeviceConfig(), m, image.IsProprietaryPath(ctx.ModuleDir(), ctx.DeviceConfig()), apexInfo, image) {
-			return true
-		}
-	}
-	return false
-}
diff --git a/cc/testing.go b/cc/testing.go
index 3bdc383..2aecd5f 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -15,14 +15,12 @@
 package cc
 
 import (
-	"encoding/json"
 	"path/filepath"
 	"testing"
 
 	"android/soong/android"
 	"android/soong/genrule"
 	"android/soong/multitree"
-	"android/soong/snapshot"
 )
 
 func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
@@ -702,10 +700,6 @@
 	ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
 	ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
 
-	snapshot.VendorSnapshotImageSingleton.Init(ctx)
-	snapshot.RecoverySnapshotImageSingleton.Init(ctx)
-	RegisterVendorSnapshotModules(ctx)
-	RegisterRecoverySnapshotModules(ctx)
 	RegisterVndkLibraryTxtTypes(ctx)
 
 	ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
@@ -759,14 +753,6 @@
 	checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, true)
 }
 
-func AssertExcludeFromVendorSnapshotIs(t *testing.T, ctx *android.TestContext, name string, expected bool, variant string) {
-	t.Helper()
-	m := ctx.ModuleForTests(name, variant).Module().(LinkableInterface)
-	if m.ExcludeFromVendorSnapshot() != expected {
-		t.Errorf("expected %q ExcludeFromVendorSnapshot to be %t", m.String(), expected)
-	}
-}
-
 func GetOutputPaths(ctx *android.TestContext, variant string, moduleNames []string) (paths android.Paths) {
 	for _, moduleName := range moduleNames {
 		module := ctx.ModuleForTests(moduleName, variant).Module().(*Module)
@@ -775,30 +761,3 @@
 	}
 	return paths
 }
-
-func AssertExcludeFromRecoverySnapshotIs(t *testing.T, ctx *android.TestContext, name string, expected bool, variant string) {
-	t.Helper()
-	m := ctx.ModuleForTests(name, variant).Module().(LinkableInterface)
-	if m.ExcludeFromRecoverySnapshot() != expected {
-		t.Errorf("expected %q ExcludeFromRecoverySnapshot to be %t", m.String(), expected)
-	}
-}
-
-func checkOverrides(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, jsonPath string, expected []string) {
-	t.Helper()
-	out := singleton.MaybeOutput(jsonPath)
-	content := android.ContentFromFileRuleForTests(t, ctx, out)
-
-	var flags snapshotJsonFlags
-	if err := json.Unmarshal([]byte(content), &flags); err != nil {
-		t.Errorf("Error while unmarshalling json %q: %s", jsonPath, err.Error())
-		return
-	}
-
-	for _, moduleName := range expected {
-		if !android.InList(moduleName, flags.Overrides) {
-			t.Errorf("expected %q to be in %q: %q", moduleName, flags.Overrides, content)
-			return
-		}
-	}
-}
diff --git a/cc/util.go b/cc/util.go
index d6089ab..3ede8ff 100644
--- a/cc/util.go
+++ b/cc/util.go
@@ -19,7 +19,6 @@
 	"strings"
 
 	"android/soong/android"
-	"android/soong/snapshot"
 )
 
 // Efficiently converts a list of include directories to a single string
@@ -101,6 +100,12 @@
 		"ln -sf " + target + " " + filepath.Join(dir, linkName)
 }
 
+func WriteStringToFileRule(ctx android.SingletonContext, content, out string) android.OutputPath {
+	outPath := android.PathForOutput(ctx, out)
+	android.WriteFileRule(ctx, outPath, content)
+	return outPath
+}
+
 // Dump a map to a list file as:
 //
 // {key1} {value1}
@@ -116,5 +121,5 @@
 		txtBuilder.WriteString(" ")
 		txtBuilder.WriteString(m[k])
 	}
-	return snapshot.WriteStringToFileRule(ctx, txtBuilder.String(), path)
+	return WriteStringToFileRule(ctx, txtBuilder.String(), path)
 }
diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go
deleted file mode 100644
index a33ed5f..0000000
--- a/cc/vendor_snapshot.go
+++ /dev/null
@@ -1,459 +0,0 @@
-// Copyright 2020 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//	http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package cc
-
-import (
-	"encoding/json"
-	"path/filepath"
-	"strings"
-
-	"android/soong/android"
-	"android/soong/snapshot"
-)
-
-// This file defines how to capture cc modules into snapshot package.
-
-// Checks if the target image would contain VNDK
-func includeVndk(image snapshot.SnapshotImage) bool {
-	if image.ImageName() == snapshot.VendorSnapshotImageName {
-		return true
-	}
-
-	return false
-}
-
-// Check if the module is VNDK private
-func isPrivate(image snapshot.SnapshotImage, m LinkableInterface) bool {
-	if image.ImageName() == snapshot.VendorSnapshotImageName && m.IsVndkPrivate() {
-		return true
-	}
-
-	return false
-}
-
-// Checks if target image supports VNDK Ext
-func supportsVndkExt(image snapshot.SnapshotImage) bool {
-	if image.ImageName() == snapshot.VendorSnapshotImageName {
-		return true
-	}
-
-	return false
-}
-
-// Determines if the module is a candidate for snapshot.
-func isSnapshotAware(cfg android.DeviceConfig, m LinkableInterface, inProprietaryPath bool, apexInfo android.ApexInfo, image snapshot.SnapshotImage) bool {
-	if !m.Enabled() || m.HiddenFromMake() {
-		return false
-	}
-	// When android/prebuilt.go selects between source and prebuilt, it sets
-	// HideFromMake on the other one to avoid duplicate install rules in make.
-	if m.IsHideFromMake() {
-		return false
-	}
-	// skip proprietary modules, but (for the vendor snapshot only)
-	// include all VNDK (static)
-	if inProprietaryPath && (!includeVndk(image) || !m.IsVndk()) {
-		return false
-	}
-	// If the module would be included based on its path, check to see if
-	// the module is marked to be excluded. If so, skip it.
-	if image.ExcludeFromSnapshot(m) {
-		return false
-	}
-	if m.Target().Os.Class != android.Device {
-		return false
-	}
-	if m.Target().NativeBridge == android.NativeBridgeEnabled {
-		return false
-	}
-	// the module must be installed in target image
-	if !apexInfo.IsForPlatform() || m.IsSnapshotPrebuilt() || !image.InImage(m)() {
-		return false
-	}
-	// skip kernel_headers which always depend on vendor
-	if m.KernelHeadersDecorator() {
-		return false
-	}
-
-	if m.IsLlndk() {
-		return false
-	}
-
-	// Libraries
-	if sanitizable, ok := m.(PlatformSanitizeable); ok && sanitizable.IsSnapshotLibrary() {
-		if sanitizable.SanitizePropDefined() {
-			// scs exports both sanitized and unsanitized variants for static and header
-			// Always use unsanitized variant of it.
-			if !sanitizable.Shared() && sanitizable.IsSanitizerEnabled(scs) {
-				return false
-			}
-			// cfi and hwasan cannot be enabled at the same time.
-			// Skip variants that have both cfi and hwasan enabled.
-			if sanitizable.IsSanitizerEnabled(cfi) && sanitizable.IsSanitizerEnabled(Hwasan) {
-				return false
-			}
-			// cfi and hwasan also export both variants. But for static, we capture both.
-			// This is because cfi static libraries can't be linked from non-cfi modules,
-			// and vice versa.
-			// hwasan is captured as well to support hwasan build.
-			if !sanitizable.Static() &&
-				!sanitizable.Shared() &&
-				(sanitizable.IsSanitizerEnabled(cfi) || sanitizable.IsSanitizerEnabled(Hwasan)) {
-				return false
-			}
-		}
-		if sanitizable.Static() || sanitizable.Rlib() {
-			return sanitizable.OutputFile().Valid() && !isPrivate(image, m)
-		}
-		if sanitizable.Shared() || sanitizable.Dylib() {
-			if !sanitizable.OutputFile().Valid() {
-				return false
-			}
-			if includeVndk(image) {
-				if !sanitizable.IsVndk() {
-					return true
-				}
-				return sanitizable.IsVndkExt()
-			}
-		}
-		return true
-	}
-
-	// Binaries and Objects
-	if m.Binary() || m.Object() {
-		return m.OutputFile().Valid()
-	}
-
-	return false
-}
-
-// Extend the snapshot.SnapshotJsonFlags to include cc specific fields.
-type snapshotJsonFlags struct {
-	snapshot.SnapshotJsonFlags
-	// library flags
-	ExportedDirs       []string `json:",omitempty"`
-	ExportedSystemDirs []string `json:",omitempty"`
-	ExportedFlags      []string `json:",omitempty"`
-	Sanitize           string   `json:",omitempty"`
-	SanitizeMinimalDep bool     `json:",omitempty"`
-	SanitizeUbsanDep   bool     `json:",omitempty"`
-
-	// binary flags
-	Symlinks         []string `json:",omitempty"`
-	StaticExecutable bool     `json:",omitempty"`
-	InstallInRoot    bool     `json:",omitempty"`
-
-	// dependencies
-	SharedLibs  []string `json:",omitempty"`
-	StaticLibs  []string `json:",omitempty"`
-	RuntimeLibs []string `json:",omitempty"`
-	Dylibs      []string `json:",omitempty"`
-	Rlibs       []string `json:",omitempty"`
-
-	// extra config files
-	InitRc         []string `json:",omitempty"`
-	VintfFragments []string `json:",omitempty"`
-	MinSdkVersion  string   `json:",omitempty"`
-}
-
-var ccSnapshotAction snapshot.GenerateSnapshotAction = func(s snapshot.SnapshotSingleton, ctx android.SingletonContext, snapshotArchDir string) snapshot.SnapshotPaths {
-	/*
-		Vendor snapshot zipped artifacts directory structure for cc modules:
-		{SNAPSHOT_ARCH}/
-			arch-{TARGET_ARCH}-{TARGET_ARCH_VARIANT}/
-				shared/
-					(.so shared libraries)
-				static/
-					(.a static libraries)
-				header/
-					(header only libraries)
-				binary/
-					(executable binaries)
-				object/
-					(.o object files)
-			arch-{TARGET_2ND_ARCH}-{TARGET_2ND_ARCH_VARIANT}/
-				shared/
-					(.so shared libraries)
-				static/
-					(.a static libraries)
-				header/
-					(header only libraries)
-				binary/
-					(executable binaries)
-				object/
-					(.o object files)
-			NOTICE_FILES/
-				(notice files, e.g. libbase.txt)
-			configs/
-				(config files, e.g. init.rc files, vintf_fragments.xml files, etc.)
-			include/
-				(header files of same directory structure with source tree)
-	*/
-
-	var snapshotOutputs android.Paths
-	var snapshotNotices android.Paths
-
-	includeDir := filepath.Join(snapshotArchDir, "include")
-	configsDir := filepath.Join(snapshotArchDir, "configs")
-
-	installedNotices := make(map[string]bool)
-	installedConfigs := make(map[string]bool)
-
-	var headers android.Paths
-
-	copyFile := func(ctx android.SingletonContext, path android.Path, out string, fake bool) android.OutputPath {
-		if fake {
-			// All prebuilt binaries and headers are installed by copyFile function. This makes a fake
-			// snapshot just touch prebuilts and headers, rather than installing real files.
-			return snapshot.WriteStringToFileRule(ctx, "", out)
-		} else {
-			return snapshot.CopyFileRule(pctx, ctx, path, out)
-		}
-	}
-
-	// installSnapshot function copies prebuilt file (.so, .a, or executable) and json flag file.
-	// For executables, init_rc and vintf_fragments files are also copied.
-	installSnapshot := func(m LinkableInterface, fake bool) android.Paths {
-		targetArch := "arch-" + m.Target().Arch.ArchType.String()
-		if m.Target().Arch.ArchVariant != "" {
-			targetArch += "-" + m.Target().Arch.ArchVariant
-		}
-
-		var ret android.Paths
-
-		prop := snapshotJsonFlags{}
-
-		// Common properties among snapshots.
-		prop.InitBaseSnapshotPropsWithName(m, ctx.ModuleName(m))
-		if supportsVndkExt(s.Image) && m.IsVndkExt() {
-			// vndk exts are installed to /vendor/lib(64)?/vndk(-sp)?
-			if m.IsVndkSp() {
-				prop.RelativeInstallPath = "vndk-sp"
-			} else {
-				prop.RelativeInstallPath = "vndk"
-			}
-		} else {
-			prop.RelativeInstallPath = m.RelativeInstallPath()
-		}
-		prop.RuntimeLibs = m.SnapshotRuntimeLibs()
-		prop.Required = m.RequiredModuleNames()
-		if o, ok := m.(overridable); ok {
-			prop.Overrides = o.overriddenModules()
-		}
-		for _, path := range m.InitRc() {
-			prop.InitRc = append(prop.InitRc, filepath.Join("configs", path.Base()))
-		}
-		for _, path := range m.VintfFragments() {
-			prop.VintfFragments = append(prop.VintfFragments, filepath.Join("configs", path.Base()))
-		}
-		if m.IsPrebuilt() {
-			prop.MinSdkVersion = "apex_inherit"
-		} else {
-			prop.MinSdkVersion = m.MinSdkVersion()
-		}
-
-		// install config files. ignores any duplicates.
-		for _, path := range append(m.InitRc(), m.VintfFragments()...) {
-			out := filepath.Join(configsDir, path.Base())
-			if !installedConfigs[out] {
-				installedConfigs[out] = true
-				ret = append(ret, copyFile(ctx, path, out, fake))
-			}
-		}
-
-		var propOut string
-
-		if m.IsSnapshotLibrary() {
-			exporterInfo, _ := android.SingletonModuleProvider(ctx, m.Module(), FlagExporterInfoProvider)
-
-			// library flags
-			prop.ExportedFlags = exporterInfo.Flags
-			for _, dir := range exporterInfo.IncludeDirs {
-				prop.ExportedDirs = append(prop.ExportedDirs, filepath.Join("include", dir.String()))
-			}
-			for _, dir := range exporterInfo.SystemIncludeDirs {
-				prop.ExportedSystemDirs = append(prop.ExportedSystemDirs, filepath.Join("include", dir.String()))
-			}
-
-			// shared libs dependencies aren't meaningful on static or header libs
-			if m.Shared() {
-				prop.SharedLibs = m.SnapshotSharedLibs()
-			}
-
-			// dylibs collect both shared and dylib dependencies.
-			if m.Dylib() {
-				prop.SharedLibs = m.SnapshotSharedLibs()
-				prop.Dylibs = m.SnapshotDylibs()
-			}
-
-			// static and rlib libs dependencies are required to collect the NOTICE files.
-			prop.StaticLibs = m.SnapshotStaticLibs()
-			prop.Rlibs = m.SnapshotRlibs()
-
-			if sanitizable, ok := m.(PlatformSanitizeable); ok {
-				if sanitizable.Static() && sanitizable.SanitizePropDefined() {
-					prop.SanitizeMinimalDep = sanitizable.MinimalRuntimeDep() || sanitizable.MinimalRuntimeNeeded()
-					prop.SanitizeUbsanDep = sanitizable.UbsanRuntimeDep() || sanitizable.UbsanRuntimeNeeded()
-				}
-			}
-
-			var libType string
-			if m.Static() {
-				libType = "static"
-			} else if m.Shared() {
-				libType = "shared"
-			} else if m.Rlib() {
-				libType = "rlib"
-			} else if m.Dylib() {
-				libType = "dylib"
-			} else {
-				libType = "header"
-			}
-
-			var stem string
-
-			// install .a, .rlib, .dylib.so, or .so
-			if libType != "header" {
-				libPath := m.OutputFile().Path()
-				stem = libPath.Base()
-				if sanitizable, ok := m.(PlatformSanitizeable); ok {
-					if (sanitizable.Static() || sanitizable.Rlib()) && sanitizable.SanitizePropDefined() {
-						if sanitizable.IsSanitizerEnabled(cfi) {
-							// both cfi and non-cfi variant for static libraries can exist.
-							// attach .cfi to distinguish between cfi and non-cfi.
-							// e.g. libbase.a -> libbase.cfi.a
-							ext := filepath.Ext(stem)
-							stem = strings.TrimSuffix(stem, ext) + ".cfi" + ext
-							prop.Sanitize = "cfi"
-							prop.ModuleName += ".cfi"
-						} else if sanitizable.IsSanitizerEnabled(Hwasan) {
-							// Same for the hwasan
-							ext := filepath.Ext(stem)
-							stem = strings.TrimSuffix(stem, ext) + ".hwasan" + ext
-							prop.Sanitize = "hwasan"
-							prop.ModuleName += ".hwasan"
-						}
-					}
-				}
-				if m.Rlib() && m.RlibStd() {
-					// rlibs produce both rlib-std and dylib-std variants
-					ext := filepath.Ext(stem)
-					stem = strings.TrimSuffix(stem, ext) + ".rlib-std" + ext
-					prop.ModuleName += ".rlib-std"
-				}
-				snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, libType, m.RelativeInstallPath(), stem)
-				ret = append(ret, copyFile(ctx, libPath, snapshotLibOut, fake))
-			} else {
-				stem = ctx.ModuleName(m)
-			}
-
-			propOut = filepath.Join(snapshotArchDir, targetArch, libType, m.RelativeInstallPath(), stem+".json")
-		} else if m.Binary() {
-			// binary flags
-			prop.Symlinks = m.Symlinks()
-			prop.StaticExecutable = m.StaticExecutable()
-			prop.InstallInRoot = m.InstallInRoot()
-			prop.SharedLibs = m.SnapshotSharedLibs()
-			prop.Dylibs = m.SnapshotDylibs()
-
-			// static and rlib dependencies are required to collect the NOTICE files.
-			prop.StaticLibs = m.SnapshotStaticLibs()
-			prop.Rlibs = m.SnapshotRlibs()
-
-			// install bin
-			binPath := m.OutputFile().Path()
-			snapshotBinOut := filepath.Join(snapshotArchDir, targetArch, "binary", binPath.Base())
-			ret = append(ret, copyFile(ctx, binPath, snapshotBinOut, fake))
-			propOut = snapshotBinOut + ".json"
-		} else if m.Object() {
-			// object files aren't installed to the device, so their names can conflict.
-			// Use module name as stem.
-			objPath := m.OutputFile().Path()
-			snapshotObjOut := filepath.Join(snapshotArchDir, targetArch, "object",
-				ctx.ModuleName(m)+filepath.Ext(objPath.Base()))
-			ret = append(ret, copyFile(ctx, objPath, snapshotObjOut, fake))
-			propOut = snapshotObjOut + ".json"
-		} else {
-			ctx.Errorf("unknown module %q in vendor snapshot", m.String())
-			return nil
-		}
-
-		j, err := json.Marshal(prop)
-		if err != nil {
-			ctx.Errorf("json marshal to %q failed: %#v", propOut, err)
-			return nil
-		}
-		ret = append(ret, snapshot.WriteStringToFileRule(ctx, string(j), propOut))
-
-		return ret
-	}
-
-	ctx.VisitAllModules(func(module android.Module) {
-		m, ok := module.(LinkableInterface)
-		if !ok {
-			return
-		}
-
-		moduleDir := ctx.ModuleDir(module)
-		inProprietaryPath := s.Image.IsProprietaryPath(moduleDir, ctx.DeviceConfig())
-		apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider)
-
-		if s.Image.ExcludeFromSnapshot(m) {
-			if inProprietaryPath {
-				// Error: exclude_from_vendor_snapshot applies
-				// to framework-path modules only.
-				ctx.Errorf("module %q in vendor proprietary path %q may not use \"exclude_from_vendor_snapshot: true\"", m.String(), moduleDir)
-				return
-			}
-		}
-
-		if !isSnapshotAware(ctx.DeviceConfig(), m, inProprietaryPath, apexInfo, s.Image) {
-			return
-		}
-
-		// If we are using directed snapshot and a module is not included in the
-		// list, we will still include the module as if it was a fake module.
-		// The reason is that soong needs all the dependencies to be present, even
-		// if they are not using during the build.
-		installAsFake := s.Fake
-		if s.Image.ExcludeFromDirectedSnapshot(ctx.DeviceConfig(), m.BaseModuleName()) {
-			installAsFake = true
-		}
-
-		// installSnapshot installs prebuilts and json flag files
-		snapshotOutputs = append(snapshotOutputs, installSnapshot(m, installAsFake)...)
-		// just gather headers and notice files here, because they are to be deduplicated
-		if m.IsSnapshotLibrary() {
-			headers = append(headers, m.SnapshotHeaders()...)
-		}
-
-		for _, notice := range m.EffectiveLicenseFiles() {
-			if _, ok := installedNotices[notice.String()]; !ok {
-				installedNotices[notice.String()] = true
-				snapshotNotices = append(snapshotNotices, notice)
-			}
-		}
-	})
-
-	// install all headers after removing duplicates
-	for _, header := range android.FirstUniquePaths(headers) {
-		snapshotOutputs = append(snapshotOutputs, copyFile(ctx, header, filepath.Join(includeDir, header.String()), s.Fake))
-	}
-
-	return snapshot.SnapshotPaths{OutputFiles: snapshotOutputs, NoticeFiles: snapshotNotices}
-}
-
-func init() {
-	snapshot.RegisterSnapshotAction(ccSnapshotAction)
-}
diff --git a/cc/vndk.go b/cc/vndk.go
index ad0dcf3..14b44b6 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -15,17 +15,13 @@
 package cc
 
 import (
-	"encoding/json"
 	"errors"
 	"fmt"
-	"path/filepath"
-	"sort"
 	"strings"
 
 	"android/soong/android"
 	"android/soong/cc/config"
 	"android/soong/etc"
-	"android/soong/snapshot"
 
 	"github.com/google/blueprint"
 	"github.com/google/blueprint/proptools"
@@ -405,7 +401,6 @@
 
 func init() {
 	RegisterVndkLibraryTxtTypes(android.InitRegistrationContext)
-	android.RegisterParallelSingletonType("vndk-snapshot", VndkSnapshotSingleton)
 }
 
 func RegisterVndkLibraryTxtTypes(ctx android.RegistrationContext) {
@@ -582,248 +577,6 @@
 func (txt *vndkLibrariesTxt) OutputFiles(tag string) (android.Paths, error) {
 	return android.Paths{txt.outputFile}, nil
 }
-
-func VndkSnapshotSingleton() android.Singleton {
-	return &vndkSnapshotSingleton{}
-}
-
-type vndkSnapshotSingleton struct {
-	vndkLibrariesFile   android.OutputPath
-	vndkSnapshotZipFile android.OptionalPath
-}
-
-func isVndkSnapshotAware(config android.DeviceConfig, m LinkableInterface,
-	apexInfo android.ApexInfo) (vndkType string, isVndkSnapshotLib bool) {
-	return "", false
-}
-
-func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
-	// build these files even if PlatformVndkVersion or BoardVndkVersion is not set
-	c.buildVndkLibrariesTxtFiles(ctx)
-
-	// BOARD_VNDK_VERSION must be set to 'current' in order to generate a VNDK snapshot.
-	if ctx.DeviceConfig().VndkVersion() != "current" {
-		return
-	}
-
-	var snapshotOutputs android.Paths
-
-	/*
-		VNDK snapshot zipped artifacts directory structure:
-		{SNAPSHOT_ARCH}/
-			arch-{TARGET_ARCH}-{TARGET_ARCH_VARIANT}/
-				shared/
-					vndk-core/
-						(VNDK-core libraries, e.g. libbinder.so)
-					vndk-sp/
-						(VNDK-SP libraries, e.g. libc++.so)
-					llndk-stub/
-						(LLNDK stub libraries)
-			arch-{TARGET_2ND_ARCH}-{TARGET_2ND_ARCH_VARIANT}/
-				shared/
-					vndk-core/
-						(VNDK-core libraries, e.g. libbinder.so)
-					vndk-sp/
-						(VNDK-SP libraries, e.g. libc++.so)
-					llndk-stub/
-						(LLNDK stub libraries)
-			binder32/
-				(This directory is newly introduced in v28 (Android P) to hold
-				prebuilts built for 32-bit binder interface.)
-				arch-{TARGET_ARCH}-{TARGE_ARCH_VARIANT}/
-					...
-			configs/
-				(various *.txt configuration files)
-			include/
-				(header files of same directory structure with source tree)
-			NOTICE_FILES/
-				(notice files of libraries, e.g. libcutils.so.txt)
-	*/
-
-	snapshotDir := "vndk-snapshot"
-	snapshotArchDir := filepath.Join(snapshotDir, ctx.DeviceConfig().DeviceArch())
-
-	configsDir := filepath.Join(snapshotArchDir, "configs")
-	noticeDir := filepath.Join(snapshotArchDir, "NOTICE_FILES")
-	includeDir := filepath.Join(snapshotArchDir, "include")
-
-	// set of notice files copied.
-	noticeBuilt := make(map[string]bool)
-
-	// paths of VNDK modules for GPL license checking
-	modulePaths := make(map[string]string)
-
-	// actual module names of .so files
-	// e.g. moduleNames["libprotobuf-cpp-full-3.9.1.so"] = "libprotobuf-cpp-full"
-	moduleNames := make(map[string]string)
-
-	var headers android.Paths
-
-	// installVndkSnapshotLib copies built .so file from the module.
-	// Also, if the build artifacts is on, write a json file which contains all exported flags
-	// with FlagExporterInfo.
-	installVndkSnapshotLib := func(m *Module, vndkType string) (android.Paths, bool) {
-		var ret android.Paths
-
-		targetArch := "arch-" + m.Target().Arch.ArchType.String()
-		if m.Target().Arch.ArchVariant != "" {
-			targetArch += "-" + m.Target().Arch.ArchVariant
-		}
-
-		libPath := m.outputFile.Path()
-		snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, "shared", vndkType, libPath.Base())
-		ret = append(ret, snapshot.CopyFileRule(pctx, ctx, libPath, snapshotLibOut))
-
-		// json struct to export snapshot information
-		prop := struct {
-			MinSdkVersion       string   `json:",omitempty"`
-			LicenseKinds        []string `json:",omitempty"`
-			LicenseTexts        []string `json:",omitempty"`
-			ExportedDirs        []string `json:",omitempty"`
-			ExportedSystemDirs  []string `json:",omitempty"`
-			ExportedFlags       []string `json:",omitempty"`
-			RelativeInstallPath string   `json:",omitempty"`
-		}{}
-
-		prop.LicenseKinds = m.EffectiveLicenseKinds()
-		prop.LicenseTexts = m.EffectiveLicenseFiles().Strings()
-		prop.MinSdkVersion = m.MinSdkVersion()
-
-		if ctx.Config().VndkSnapshotBuildArtifacts() {
-			exportedInfo, _ := android.SingletonModuleProvider(ctx, m, FlagExporterInfoProvider)
-			prop.ExportedFlags = exportedInfo.Flags
-			prop.ExportedDirs = exportedInfo.IncludeDirs.Strings()
-			prop.ExportedSystemDirs = exportedInfo.SystemIncludeDirs.Strings()
-			prop.RelativeInstallPath = m.RelativeInstallPath()
-		}
-
-		propOut := snapshotLibOut + ".json"
-
-		j, err := json.Marshal(prop)
-		if err != nil {
-			ctx.Errorf("json marshal to %q failed: %#v", propOut, err)
-			return nil, false
-		}
-		ret = append(ret, snapshot.WriteStringToFileRule(ctx, string(j), propOut))
-
-		return ret, true
-	}
-
-	ctx.VisitAllModules(func(module android.Module) {
-		m, ok := module.(*Module)
-		if !ok || !m.Enabled() {
-			return
-		}
-
-		apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider)
-
-		vndkType, ok := isVndkSnapshotAware(ctx.DeviceConfig(), m, apexInfo)
-		if !ok {
-			return
-		}
-
-		// For all snapshot candidates, the followings are captured.
-		//   - .so files
-		//   - notice files
-		//
-		// The followings are also captured if VNDK_SNAPSHOT_BUILD_ARTIFACTS.
-		//   - .json files containing exported flags
-		//   - exported headers from collectHeadersForSnapshot()
-		//
-		// Headers are deduplicated after visiting all modules.
-
-		// install .so files for appropriate modules.
-		// Also install .json files if VNDK_SNAPSHOT_BUILD_ARTIFACTS
-		libs, ok := installVndkSnapshotLib(m, vndkType)
-		if !ok {
-			return
-		}
-		snapshotOutputs = append(snapshotOutputs, libs...)
-
-		// These are for generating module_names.txt and module_paths.txt
-		stem := m.outputFile.Path().Base()
-		moduleNames[stem] = ctx.ModuleName(m)
-		modulePaths[stem] = ctx.ModuleDir(m)
-
-		for _, notice := range m.EffectiveLicenseFiles() {
-			if _, ok := noticeBuilt[notice.String()]; !ok {
-				noticeBuilt[notice.String()] = true
-				snapshotOutputs = append(snapshotOutputs, snapshot.CopyFileRule(
-					pctx, ctx, notice, filepath.Join(noticeDir, notice.String())))
-			}
-		}
-
-		if ctx.Config().VndkSnapshotBuildArtifacts() {
-			headers = append(headers, m.SnapshotHeaders()...)
-		}
-	})
-
-	// install all headers after removing duplicates
-	for _, header := range android.FirstUniquePaths(headers) {
-		snapshotOutputs = append(snapshotOutputs, snapshot.CopyFileRule(
-			pctx, ctx, header, filepath.Join(includeDir, header.String())))
-	}
-
-	// install *.libraries.txt except vndkcorevariant.libraries.txt
-	ctx.VisitAllModules(func(module android.Module) {
-		m, ok := module.(*vndkLibrariesTxt)
-		if !ok || !m.Enabled() || m.Name() == vndkUsingCoreVariantLibrariesTxt {
-			return
-		}
-		snapshotOutputs = append(snapshotOutputs, snapshot.CopyFileRule(
-			pctx, ctx, m.OutputFile(), filepath.Join(configsDir, m.Name())))
-	})
-
-	/*
-		module_paths.txt contains paths on which VNDK modules are defined.
-		e.g.,
-			libbase.so system/libbase
-			libc.so bionic/libc
-			...
-	*/
-	snapshotOutputs = append(snapshotOutputs, installMapListFileRule(ctx, modulePaths, filepath.Join(configsDir, "module_paths.txt")))
-
-	/*
-		module_names.txt contains names as which VNDK modules are defined,
-		because output filename and module name can be different with stem and suffix properties.
-
-		e.g.,
-			libcutils.so libcutils
-			libprotobuf-cpp-full-3.9.2.so libprotobuf-cpp-full
-			...
-	*/
-	snapshotOutputs = append(snapshotOutputs, installMapListFileRule(ctx, moduleNames, filepath.Join(configsDir, "module_names.txt")))
-
-	// All artifacts are ready. Sort them to normalize ninja and then zip.
-	sort.Slice(snapshotOutputs, func(i, j int) bool {
-		return snapshotOutputs[i].String() < snapshotOutputs[j].String()
-	})
-
-	zipPath := android.PathForOutput(ctx, snapshotDir, "android-vndk-"+ctx.DeviceConfig().DeviceArch()+".zip")
-	zipRule := android.NewRuleBuilder(pctx, ctx)
-
-	// filenames in rspfile from FlagWithRspFileInputList might be single-quoted. Remove it with tr
-	snapshotOutputList := android.PathForOutput(ctx, snapshotDir, "android-vndk-"+ctx.DeviceConfig().DeviceArch()+"_list")
-	rspFile := snapshotOutputList.ReplaceExtension(ctx, "rsp")
-	zipRule.Command().
-		Text("tr").
-		FlagWithArg("-d ", "\\'").
-		FlagWithRspFileInputList("< ", rspFile, snapshotOutputs).
-		FlagWithOutput("> ", snapshotOutputList)
-
-	zipRule.Temporary(snapshotOutputList)
-
-	zipRule.Command().
-		BuiltTool("soong_zip").
-		FlagWithOutput("-o ", zipPath).
-		FlagWithArg("-C ", android.PathForOutput(ctx, snapshotDir).String()).
-		FlagWithInput("-l ", snapshotOutputList)
-
-	zipRule.Build(zipPath.String(), "vndk snapshot "+zipPath.String())
-	zipRule.DeleteTemporaryFiles()
-	c.vndkSnapshotZipFile = android.OptionalPathForPath(zipPath)
-}
-
 func getVndkFileName(m *Module) (string, error) {
 	if library, ok := m.linker.(*libraryDecorator); ok {
 		return library.getLibNameHelper(m.BaseModuleName(), true, false) + ".so", nil
@@ -833,43 +586,3 @@
 	}
 	return "", fmt.Errorf("VNDK library should have libraryDecorator or prebuiltLibraryLinker as linker: %T", m.linker)
 }
-
-func (c *vndkSnapshotSingleton) buildVndkLibrariesTxtFiles(ctx android.SingletonContext) {
-	// Build list of vndk libs as merged & tagged & filter-out(libclang_rt):
-	// Since each target have different set of libclang_rt.* files,
-	// keep the common set of files in vndk.libraries.txt
-	_, llndk := vndkModuleListRemover(llndkLibraries, "libclang_rt.")(ctx)
-	_, vndkcore := vndkModuleListRemover(vndkCoreLibraries, "libclang_rt.")(ctx)
-	_, vndksp := vndkSPLibraries(ctx)
-	_, vndkprivate := vndkPrivateLibraries(ctx)
-	_, vndkproduct := vndkModuleListRemover(vndkProductLibraries, "libclang_rt.")(ctx)
-	var merged []string
-	merged = append(merged, addPrefix(llndk, "LLNDK: ")...)
-	merged = append(merged, addPrefix(vndksp, "VNDK-SP: ")...)
-	merged = append(merged, addPrefix(vndkcore, "VNDK-core: ")...)
-	merged = append(merged, addPrefix(vndkprivate, "VNDK-private: ")...)
-	merged = append(merged, addPrefix(vndkproduct, "VNDK-product: ")...)
-	c.vndkLibrariesFile = android.PathForOutput(ctx, "vndk", "vndk.libraries.txt")
-	android.WriteFileRule(ctx, c.vndkLibrariesFile, strings.Join(merged, "\n"))
-}
-
-func (c *vndkSnapshotSingleton) MakeVars(ctx android.MakeVarsContext) {
-	// Make uses LLNDK_MOVED_TO_APEX_LIBRARIES to avoid installing libraries on /system if
-	// they been moved to an apex.
-	movedToApexLlndkLibraries := make(map[string]bool)
-	ctx.VisitAllModules(func(module android.Module) {
-		if library := moduleLibraryInterface(module); library != nil && library.hasLLNDKStubs() {
-			// Skip bionic libs, they are handled in different manner
-			name := library.implementationModuleName(module.(*Module).BaseModuleName())
-			if module.(android.ApexModule).DirectlyInAnyApex() && !isBionic(name) {
-				movedToApexLlndkLibraries[name] = true
-			}
-		}
-	})
-
-	ctx.Strict("LLNDK_MOVED_TO_APEX_LIBRARIES",
-		strings.Join(android.SortedKeys(movedToApexLlndkLibraries), " "))
-
-	ctx.Strict("VNDK_LIBRARIES_FILE", c.vndkLibrariesFile.String())
-	ctx.Strict("SOONG_VNDK_SNAPSHOT_ZIP", c.vndkSnapshotZipFile.String())
-}
