Remove some uses of ApexContents

In preparation for removing ApexContents in order to simplify the
Soong logic and remove the top down apex mutator, delete
ApexContents.DirectlyInApex and ApexContents.InApex.

apexBundle depVisitor doesn't need to check DirectlyInApex, it can
always follow the stubs path here, and later in buildManifest the
provideNativeLibs list is removed from requireNativeLibs.

In checkStaticLinkingToStubLibraries the apex can visit direct
dependnecies to find the included shared libraries instead of
checking the ApexContents.

Bug: 372543712
Test: all apex tests pass
Test: builds
Change-Id: Ibdad6bec9f1a810058b52a4375b5e61cdc034efb
diff --git a/apex/apex.go b/apex/apex.go
index a1879f5..a106a82 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2074,8 +2074,7 @@
 			af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)
 			af.transitiveDep = true
 
-			abInfo, _ := android.ModuleProvider(ctx, android.ApexBundleInfoProvider)
-			if !abInfo.Contents.DirectlyInApex(depName) && (ch.IsStubs() || ch.HasStubsVariants()) {
+			if ch.IsStubs() || ch.HasStubsVariants() {
 				// If the dependency is a stubs lib, don't include it in this APEX,
 				// but make sure that the lib is installed on the device.
 				// In case no APEX is having the lib, the lib is installed to the system
@@ -2579,7 +2578,10 @@
 		return
 	}
 
-	abInfo, _ := android.ModuleProvider(ctx, android.ApexBundleInfoProvider)
+	librariesDirectlyInApex := make(map[string]bool)
+	ctx.VisitDirectDepsProxyWithTag(sharedLibTag, func(dep android.ModuleProxy) {
+		librariesDirectlyInApex[ctx.OtherModuleName(dep)] = true
+	})
 
 	a.WalkPayloadDeps(ctx, func(ctx android.BaseModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
 		if ccm, ok := to.(*cc.Module); ok {
@@ -2605,7 +2607,7 @@
 				return false
 			}
 
-			isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !abInfo.Contents.DirectlyInApex(toName)
+			isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !librariesDirectlyInApex[toName]
 			if isStubLibraryFromOtherApex && !externalDep {
 				ctx.ModuleErrorf("%q required by %q is a native library providing stub. "+
 					"It shouldn't be included in this APEX via static linking. Dependency path: %s", to.String(), fromName, ctx.GetPathString(false))