Relax SDK checks for unbundled builds

Unbundled builds might not have the prebuilt/sdk files, allow
the build to continue and then fail if the module is actually
built.

Test: m -j checkbuild
Change-Id: I21163778f1cc50945c7a12e57da0e39ba963aa7c
diff --git a/java/java.go b/java/java.go
index 1ca3928..d8bc0c2 100644
--- a/java/java.go
+++ b/java/java.go
@@ -195,10 +195,11 @@
 )
 
 type sdkDep struct {
-	useModule, useFiles, useDefaultLibs bool
-	module                              string
-	jar                                 android.Path
-	aidl                                android.Path
+	useModule, useFiles, useDefaultLibs, invalidVersion bool
+
+	module string
+	jar    android.Path
+	aidl   android.Path
 }
 
 func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
@@ -218,14 +219,24 @@
 		aidl := filepath.Join(dir, "framework.aidl")
 		jarPath := android.ExistentPathForSource(ctx, "sdkdir", jar)
 		aidlPath := android.ExistentPathForSource(ctx, "sdkdir", aidl)
+
+		if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.AConfig().AllowMissingDependencies() {
+			return sdkDep{
+				invalidVersion: true,
+				module:         "sdk_v" + v,
+			}
+		}
+
 		if !jarPath.Valid() {
 			ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", v, jar)
 			return sdkDep{}
 		}
+
 		if !aidlPath.Valid() {
 			ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", v, aidl)
 			return sdkDep{}
 		}
+
 		return sdkDep{
 			useFiles: true,
 			jar:      jarPath.Path(),
@@ -323,7 +334,9 @@
 	var deps deps
 
 	sdkDep := decodeSdkDep(ctx, j.deviceProperties.Sdk_version)
-	if sdkDep.useFiles {
+	if sdkDep.invalidVersion {
+		ctx.AddMissingDependencies([]string{sdkDep.module})
+	} else if sdkDep.useFiles {
 		deps.classpath = append(deps.classpath, sdkDep.jar)
 		deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, sdkDep.aidl)
 	}