Merge "javadoc/droidoc: Don't add .jar files to sourcepath."
diff --git a/cc/cc.go b/cc/cc.go
index 4d26e84..371ea1d 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -502,10 +502,17 @@
 func (ctx *moduleContextImpl) sdkVersion() string {
 	if ctx.ctx.Device() {
 		if ctx.useVndk() {
-			return "current"
-		} else {
-			return String(ctx.mod.Properties.Sdk_version)
+			vndk_ver := ctx.ctx.DeviceConfig().VndkVersion()
+			if vndk_ver == "current" {
+				platform_vndk_ver := ctx.ctx.DeviceConfig().PlatformVndkVersion()
+				if inList(platform_vndk_ver, ctx.ctx.Config().PlatformVersionCombinedCodenames()) {
+					return "current"
+				}
+				return platform_vndk_ver
+			}
+			return vndk_ver
 		}
+		return String(ctx.mod.Properties.Sdk_version)
 	}
 	return ""
 }
diff --git a/cc/compiler.go b/cc/compiler.go
index 5ef20f0..ffb8342 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -106,6 +106,9 @@
 		// list of directories relative to the Blueprints file that will
 		// be added to the aidl include paths.
 		Local_include_dirs []string
+
+		// whether to generate traces (for systrace) for this interface
+		Generate_traces *bool
 	}
 
 	Renderscript struct {
@@ -305,8 +308,13 @@
 	}
 
 	if ctx.useVndk() {
+		// sdkVersion() returns VNDK version for vendor modules.
+		version := ctx.sdkVersion()
+		if version == "current" {
+			version = "__ANDROID_API_FUTURE__"
+		}
 		flags.GlobalFlags = append(flags.GlobalFlags,
-			"-D__ANDROID_API__=__ANDROID_API_FUTURE__", "-D__ANDROID_VNDK__")
+			"-D__ANDROID_API__="+version, "-D__ANDROID_VNDK__")
 	}
 
 	instructionSet := String(compiler.Properties.Instruction_set)
@@ -473,6 +481,10 @@
 			flags.aidlFlags = append(flags.aidlFlags, includeDirsToFlags(rootAidlIncludeDirs))
 		}
 
+		if Bool(compiler.Properties.Aidl.Generate_traces) {
+			flags.aidlFlags = append(flags.aidlFlags, "-t")
+		}
+
 		flags.GlobalFlags = append(flags.GlobalFlags,
 			"-I"+android.PathForModuleGen(ctx, "aidl").String())
 	}
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index b573c2e..6e64acf 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -76,7 +76,17 @@
 }
 
 func (stub *llndkStubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
-	objs, versionScript := compileStubLibrary(ctx, flags, String(stub.Properties.Symbol_file), "current", "--vndk")
+	vndk_ver := ctx.DeviceConfig().VndkVersion()
+	if vndk_ver == "current" {
+		platform_vndk_ver := ctx.DeviceConfig().PlatformVndkVersion()
+		if !inList(platform_vndk_ver, ctx.Config().PlatformVersionCombinedCodenames()) {
+			vndk_ver = platform_vndk_ver
+		}
+	} else if vndk_ver == "" {
+		// For non-enforcing devices, use "current"
+		vndk_ver = "current"
+	}
+	objs, versionScript := compileStubLibrary(ctx, flags, String(stub.Properties.Symbol_file), vndk_ver, "--vndk")
 	stub.versionScriptPath = versionScript
 	return objs
 }
diff --git a/java/java.go b/java/java.go
index 3feb838..06dce05 100644
--- a/java/java.go
+++ b/java/java.go
@@ -178,6 +178,9 @@
 		// directories that should be added as include directories for any aidl sources of modules
 		// that depend on this module, as well as to aidl for this module.
 		Export_include_dirs []string
+
+		// whether to generate traces (for systrace) for this interface
+		Generate_traces *bool
 	}
 
 	// If true, export a copy of the module as a -hostdex module for host testing.
@@ -558,6 +561,10 @@
 		flags = append(flags, "-I"+src.String())
 	}
 
+	if Bool(j.deviceProperties.Aidl.Generate_traces) {
+		flags = append(flags, "-t")
+	}
+
 	return flags
 }