Convert getFdoProfilePathFromDep and addStubDependencyProviders to use
ModuleProxy.

Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: If06de5f852e6e4574ce0e383ba0bc4fc3508b4b4
diff --git a/cc/afdo.go b/cc/afdo.go
index 03dc271..828e494 100644
--- a/cc/afdo.go
+++ b/cc/afdo.go
@@ -65,8 +65,8 @@
 }
 
 func getFdoProfilePathFromDep(ctx ModuleContext) string {
-	fdoProfileDeps := ctx.GetDirectDepsWithTag(FdoProfileTag)
-	if len(fdoProfileDeps) > 0 && fdoProfileDeps[0] != nil {
+	fdoProfileDeps := ctx.GetDirectDepsProxyWithTag(FdoProfileTag)
+	if len(fdoProfileDeps) > 0 {
 		if info, ok := android.OtherModuleProvider(ctx, fdoProfileDeps[0], FdoProfileProvider); ok {
 			return info.Path.String()
 		}
diff --git a/cc/cc.go b/cc/cc.go
index 18bffb5..dff8348 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -93,6 +93,11 @@
 type LibraryDecoratorInfo struct {
 	ExportIncludeDirs proptools.Configurable[[]string]
 }
+
+type LibraryInfo struct {
+	StubsVersion string
+}
+
 type TestBinaryInfo struct {
 	Gtest bool
 }
@@ -106,6 +111,7 @@
 	CmakeSnapshotSupported bool
 	CompilerInfo           *CompilerInfo
 	LinkerInfo             *LinkerInfo
+	LibraryInfo            *LibraryInfo
 }
 
 var CcInfoProvider = blueprint.NewProvider[CcInfo]()
@@ -2227,6 +2233,11 @@
 			ccInfo.LinkerInfo.ObjectLinkerInfo = &ObjectLinkerInfo{}
 		}
 	}
+	if c.library != nil {
+		ccInfo.LibraryInfo = &LibraryInfo{
+			StubsVersion: c.library.stubsVersion(),
+		}
+	}
 	android.SetProvider(ctx, CcInfoProvider, ccInfo)
 
 	c.setOutputFiles(ctx)
diff --git a/cc/library.go b/cc/library.go
index be27b01..c9114fd 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1216,7 +1216,7 @@
 // Visits the stub variants of the library and returns a struct containing the stub .so paths
 func addStubDependencyProviders(ctx ModuleContext) []SharedStubLibrary {
 	stubsInfo := []SharedStubLibrary{}
-	stubs := ctx.GetDirectDepsWithTag(stubImplDepTag)
+	stubs := ctx.GetDirectDepsProxyWithTag(stubImplDepTag)
 	if len(stubs) > 0 {
 		for _, stub := range stubs {
 			stubInfo, ok := android.OtherModuleProvider(ctx, stub, SharedLibraryInfoProvider)
@@ -1225,8 +1225,12 @@
 				continue
 			}
 			flagInfo, _ := android.OtherModuleProvider(ctx, stub, FlagExporterInfoProvider)
+			ccInfo, ok := android.OtherModuleProvider(ctx, stub, CcInfoProvider)
+			if !ok || ccInfo.LibraryInfo == nil {
+				panic(fmt.Errorf("couldn't find library info for %s", stub))
+			}
 			stubsInfo = append(stubsInfo, SharedStubLibrary{
-				Version:           moduleLibraryInterface(stub).stubsVersion(),
+				Version:           ccInfo.LibraryInfo.StubsVersion,
 				SharedLibraryInfo: stubInfo,
 				FlagExporterInfo:  flagInfo,
 			})