Split DepIsInSameApex into outgoing and incoming

Prepare for calling DepIsInSameApex from the apex transition mutator
by splitting all the implementations in two, one that is called on the
outgoing module and only takes the depTag, and one that is called on the
incoming module and only takes the depTag.

apexBundle.depVisitor was passing the child into android.IsDepInSameApex
for both the parent and child paramters.  The parent field was only
used to find the type on which to call DepIsInSameApex, so this
effectively used the child's implementation of DepIsInSameApex.  That
used to be necessary when the parent and child were of different
module types, as the parent module type may not have been aware
of the rules for the child module type, but is no longer necessary
with split outgoing and incoming DepIsInSameApex.

Bug: 372543712
Test: all soong tests pass
Change-Id: If7c81ec3f7b1ea69d77e9ad7694e238820194e59
diff --git a/apex/apex.go b/apex/apex.go
index 912780d..fb0d730 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1222,7 +1222,13 @@
 var _ android.DepIsInSameApex = (*apexBundle)(nil)
 
 // Implements android.DepInInSameApex
-func (a *apexBundle) DepIsInSameApex(_ android.BaseModuleContext, _ android.Module) bool {
+func (a *apexBundle) OutgoingDepIsInSameApex(tag blueprint.DependencyTag) bool {
+	// direct deps of an APEX bundle are all part of the APEX bundle
+	// TODO(jiyong): shouldn't we look into the payload field of the dependencyTag?
+	return true
+}
+
+func (a *apexBundle) IncomingDepIsInSameApex(tag blueprint.DependencyTag) bool {
 	// direct deps of an APEX bundle are all part of the APEX bundle
 	// TODO(jiyong): shouldn't we look into the payload field of the dependencyTag?
 	return true
@@ -2109,17 +2115,14 @@
 			// like to record requiredNativeLibs even when
 			// DepIsInSameAPex is false. We also shouldn't do
 			// this for host.
-			//
-			// TODO(jiyong): explain why the same module is passed in twice.
-			// Switching the first am to parent breaks lots of tests.
-			if !android.IsDepInSameApex(ctx, am, am) {
+			if !android.IsDepInSameApex(ctx, parent, am) {
 				return false
 			}
 
 			vctx.filesInfo = append(vctx.filesInfo, af)
 			return true // track transitive dependencies
 		} else if rm, ok := child.(*rust.Module); ok {
-			if !android.IsDepInSameApex(ctx, am, am) {
+			if !android.IsDepInSameApex(ctx, parent, am) {
 				return false
 			}