apex_available is defaultable

Previously, it was defaultable only for cc_library. Now, it is
defaultable for all module types.

Bug: 128708192
Test: m
Change-Id: If248f593da6f4b724bf889ccd7f2e077d48069b5
diff --git a/android/defaults.go b/android/defaults.go
index f489c02..7597446 100644
--- a/android/defaults.go
+++ b/android/defaults.go
@@ -151,7 +151,8 @@
 	module.AddProperties(
 		&hostAndDeviceProperties{},
 		commonProperties,
-		&variableProperties{})
+		&variableProperties{},
+		&ApexProperties{})
 
 	InitArchModule(module)
 	InitDefaultableModule(module)
diff --git a/apex/apex.go b/apex/apex.go
index 45184b5..d467b12 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1148,12 +1148,12 @@
 	})
 
 	// check apex_available requirements
-	if !ctx.Host() {
+	if !ctx.Host() && !a.testApex {
 		for _, fi := range filesInfo {
 			if am, ok := fi.module.(android.ApexModule); ok {
 				if !am.AvailableFor(ctx.ModuleName()) {
 					ctx.ModuleErrorf("requires %q that is not available for the APEX", fi.module.Name())
-					return
+					// don't stop so that we can report other violations in the same run
 				}
 			}
 		}
diff --git a/cc/cc.go b/cc/cc.go
index f306a00..733bda6 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2459,7 +2459,6 @@
 		&PgoProperties{},
 		&XomProperties{},
 		&android.ProtoProperties{},
-		&android.ApexProperties{},
 	)
 
 	android.InitDefaultsModule(module)