Add trace flag for cpp/Java AIDL generation.

The AIDL code generator can now include trace code in every generated
AIDL call. We don't want to enable this by default for all interfaces
for two reasons:
1) Potential performance overhead
2) For Java targets, the code depends on @hide APIs in android.os.Trace,
   and I haven't found a clean way to determine whether a target is
   allowed to use @hide stuff in the SDK. LOCAL_PRIVATE_PLATFORM_APIS
   is almost it, but it's not set for the core framework (which is
   exactly one of the things we'd like to trace).

Bug: 74416314
Test: verify correct code is generated when flag is set
Change-Id: Ic6ab8aee3e708207813da3e803911a844ff3e52b
Merged-In: Ic6ab8aee3e708207813da3e803911a844ff3e52b
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
 }