Snap for 10235775 from d53ab919f0e48a33a2dd3fe560f679bdf94c5b02 to simpleperf-release

Change-Id: I421c049456d3162830583b5392655c37da295ea6
diff --git a/Android.bp b/Android.bp
index a549839..7920a1a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -203,6 +203,7 @@
         cc: [
             "aidl-bugs@google.com",
         ],
+        triage_assignee: "smoreland@google.com",
     },
 
     srcs: [
@@ -231,20 +232,24 @@
     srcs: ["tests/aidl_integration_test.py"],
     test_config: "tests/aidl_integration_test.xml",
     target_required: [
+        "aidl_test_rust_service_async",
+    ],
+    data: [
+        ":aidl_test_java_client",
+        ":aidl_test_java_service",
+        ":aidl_test_java_client_sdk1",
+        ":aidl_test_java_service_sdk1",
+        ":aidl_test_java_client_sdk29",
+        ":aidl_test_java_service_sdk29",
+        ":aidl_test_java_client_permission",
+        ":aidl_test_java_service_permission",
+    ],
+    data_device_bins_both: [
         "aidl_test_client",
         "aidl_test_client_ndk",
         "aidl_test_service",
-        "aidl_test_java_client",
-        "aidl_test_java_service",
         "aidl_test_rust_client",
         "aidl_test_rust_service",
-        "aidl_test_rust_service_async",
-        "aidl_test_java_client_sdk1",
-        "aidl_test_java_service_sdk1",
-        "aidl_test_java_client_sdk29",
-        "aidl_test_java_service_sdk29",
-        "aidl_test_java_client_permission",
-        "aidl_test_java_service_permission",
     ],
     test_suites: ["general-tests"],
     test_options: {
@@ -644,6 +649,7 @@
     defaults: ["aidl_test_java_integration_defaults"],
     static_libs: [
         "aidl-test-interface-permission-java",
+        "frameworks-base-testutils",
     ],
     srcs: [
         "tests/java/src/android/aidl/permission/tests/*.java",
@@ -659,6 +665,7 @@
     defaults: ["aidl_test_java_integration_defaults"],
     static_libs: [
         "aidl-test-interface-permission-java",
+        "frameworks-base-testutils",
     ],
     data: [
         ":cts-dalvik-device-test-runner",
diff --git a/aidl_checkapi.cpp b/aidl_checkapi.cpp
index a18a8f8..8eef17d 100644
--- a/aidl_checkapi.cpp
+++ b/aidl_checkapi.cpp
@@ -87,9 +87,8 @@
       AidlAnnotation::Type::JAVA_DEFAULT,
       AidlAnnotation::Type::JAVA_DELEGATOR,
       AidlAnnotation::Type::JAVA_ONLY_IMMUTABLE,
+      AidlAnnotation::Type::JAVA_PASSTHROUGH,
       AidlAnnotation::Type::JAVA_SUPPRESS_LINT,
-      // @Backing for a enum type is checked by the enum checker
-      AidlAnnotation::Type::BACKING,
       // @RustDerive doesn't affect read/write
       AidlAnnotation::Type::RUST_DERIVE,
       AidlAnnotation::Type::SUPPRESS_WARNINGS,
@@ -365,11 +364,6 @@
 
 static bool are_compatible_enums(const AidlEnumDeclaration& older,
                                  const AidlEnumDeclaration& newer) {
-  if (!are_compatible_types(older.GetBackingType(), newer.GetBackingType())) {
-    AIDL_ERROR(newer) << "Changed backing types.";
-    return false;
-  }
-
   std::map<std::string, const AidlConstantValue*> old_enum_map;
   for (const auto& enumerator : older.GetEnumerators()) {
     old_enum_map[enumerator->GetName()] = enumerator->GetValue();
diff --git a/aidl_language.cpp b/aidl_language.cpp
index 6720818..06af907 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -1097,6 +1097,7 @@
                        const Comments& comments, int id)
     : AidlMember(location, comments),
       oneway_(oneway),
+      oneway_annotation_(oneway),
       type_(type),
       name_(name),
       arguments_(std::move(*args)),
@@ -1707,7 +1708,7 @@
 AidlInterface::AidlInterface(const AidlLocation& location, const std::string& name,
                              const Comments& comments, bool oneway, const std::string& package,
                              std::vector<std::unique_ptr<AidlMember>>* members)
-    : AidlDefinedType(location, name, comments, package, members) {
+    : AidlDefinedType(location, name, comments, package, members), oneway_annotation_(oneway) {
   for (auto& m : GetMethods()) {
     m.get()->ApplyInterfaceOneway(oneway);
   }
diff --git a/aidl_language.h b/aidl_language.h
index 3b1c77d..f963edb 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -878,6 +878,7 @@
   // set if this method is part of an interface that is marked oneway
   void ApplyInterfaceOneway(bool oneway) { oneway_ = oneway_ || oneway; }
   bool IsOneway() const { return oneway_; }
+  bool HasOnewayAnnotation() const { return oneway_annotation_; }
 
   const std::string& GetName() const { return name_; }
   bool HasId() const { return has_id_; }
@@ -917,7 +918,11 @@
   void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
 
  private:
+  // oneway_ may be set by the method or the parent interface. If the interface is oneway,
+  // is also oneway. oneway_annotation_ may only be set on creation, and may not be overridden
+  // by the parent interface. It is used to detect redundant oneway annotations.
   bool oneway_;
+  bool oneway_annotation_;
   std::unique_ptr<AidlTypeSpecifier> type_;
   std::string name_;
   const std::vector<std::unique_ptr<AidlArgument>> arguments_;
@@ -1215,6 +1220,10 @@
   bool UsesPermissions() const;
   std::string GetDescriptor() const;
   void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
+  bool HasOnewayAnnotation() const { return oneway_annotation_; }
+
+ private:
+  bool oneway_annotation_;
 };
 
 inline std::string SimpleName(const std::string& qualified_name) {
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 7111a86..e137eb3 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -2932,6 +2932,15 @@
   EXPECT_TRUE(::android::aidl::check_api(options, io_delegate_));
 }
 
+TEST_F(AidlTest, JavaPassthroughAnnotationAddedInCheckApi) {
+  Options options = Options::From("aidl --checkapi old new");
+  io_delegate_.SetFileContents("old/p/IFoo.aidl", "package p; interface IFoo{}");
+  io_delegate_.SetFileContents("new/p/IFoo.aidl",
+                               "package p; @JavaPassthrough(annotation=\"@foo\") interface IFoo{}");
+
+  EXPECT_TRUE(::android::aidl::check_api(options, io_delegate_));
+}
+
 TEST_F(AidlTest, SuccessOnIdenticalApiDumps) {
   Options options = Options::From("aidl --checkapi old new");
   io_delegate_.SetFileContents("old/p/IFoo.aidl", "package p; interface IFoo{ void foo();}");
@@ -3615,27 +3624,6 @@
   EXPECT_EQ(expected_stderr, GetCapturedStderr());
 }
 
-TEST_F(AidlTestIncompatibleChanges, ChangedBackingTypeOfEnum) {
-  const string expected_stderr =
-      "ERROR: new/p/Foo.aidl:1.11-32: Type changed: byte to long.\n"
-      "ERROR: new/p/Foo.aidl:1.36-40: Changed backing types.\n";
-  io_delegate_.SetFileContents("old/p/Foo.aidl",
-                               "package p;"
-                               "@Backing(type=\"byte\")"
-                               "enum Foo {"
-                               " FOO, BAR,"
-                               "}");
-  io_delegate_.SetFileContents("new/p/Foo.aidl",
-                               "package p;"
-                               "@Backing(type=\"long\")"
-                               "enum Foo {"
-                               " FOO, BAR,"
-                               "}");
-  CaptureStderr();
-  EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
-  EXPECT_EQ(expected_stderr, GetCapturedStderr());
-}
-
 TEST_F(AidlTestIncompatibleChanges, ChangedFixedSizeArraySize) {
   const string expected_stderr =
       "ERROR: new/p/Data.aidl:1.28-33: Type changed: int[8] to int[9].\n";
@@ -3655,17 +3643,18 @@
 }
 
 TEST_F(AidlTestIncompatibleChanges, ChangedAnnatationParams) {
+  // this is also the test for backing type remaining the same
   const string expected_stderr =
-      "ERROR: new/p/Foo.aidl:1.55-59: Changed annotations: @JavaPassthrough(annotation=\"Alice\") "
-      "to @JavaPassthrough(annotation=\"Bob\")\n";
+      "ERROR: new/p/Foo.aidl:1.36-40: Changed annotations: @Backing(type=\"int\") "
+      "to @Backing(type=\"long\")\n";
   io_delegate_.SetFileContents("old/p/Foo.aidl",
                                "package p;"
-                               "@JavaPassthrough(annotation=\"Alice\")"
-                               "parcelable Foo {}");
+                               "@Backing(type=\"int\")"
+                               "enum Foo {A}");
   io_delegate_.SetFileContents("new/p/Foo.aidl",
                                "package p;"
-                               "@JavaPassthrough(annotation=\"Bob\")"
-                               "parcelable Foo {}");
+                               "@Backing(type=\"long\")"
+                               "enum Foo {A}");
 
   CaptureStderr();
   EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
diff --git a/build/Android.bp b/build/Android.bp
index 6e4a97f..85e3f3d 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -118,6 +118,24 @@
 }
 
 aidl_interface {
+    name: "test-piece-vendor-only",
+    local_include_dir: "tests_1",
+    vendor: true,
+    flags: ["-Werror"],
+    srcs: [
+        "tests_1/some_package/IFoo.aidl",
+        "tests_1/some_package/Thing.aidl",
+        "tests_1/some_package/sub_package/*.aidl", // testing glob w/o filegroup
+    ],
+    unstable: true,
+    backend: {
+        rust: {
+            enabled: true,
+        },
+    },
+}
+
+aidl_interface {
     name: "test-piece-ndk-sdk-29",
     local_include_dir: "tests_1",
     flags: ["-Werror"],
@@ -227,6 +245,7 @@
     local_include_dir: "tests_vintf",
     srcs: ["tests_vintf/vintf/IFoo.aidl"],
     stability: "vintf",
+    vendor_available: true,
     backend: {
         rust: {
             enabled: true,
diff --git a/build/aidl_api.go b/build/aidl_api.go
index e6256d6..8424ef0 100644
--- a/build/aidl_api.go
+++ b/build/aidl_api.go
@@ -724,7 +724,7 @@
 }
 
 func init() {
-	android.RegisterSingletonType("aidl-freeze-api", freezeApiSingletonFactory)
+	android.RegisterParallelSingletonType("aidl-freeze-api", freezeApiSingletonFactory)
 }
 
 func freezeApiSingletonFactory() android.Singleton {
diff --git a/build/aidl_gen_rule.go b/build/aidl_gen_rule.go
index 9e7c950..676f120 100644
--- a/build/aidl_gen_rule.go
+++ b/build/aidl_gen_rule.go
@@ -28,20 +28,28 @@
 
 var (
 	aidlDirPrepareRule = pctx.StaticRule("aidlDirPrepareRule", blueprint.RuleParams{
-		Command: `rm -rf "${outDir}" && mkdir -p "${outDir}" && ` +
-			`touch ${out} # ${in}`,
+		Command:     `mkdir -p "${outDir}" && touch ${out} # ${in}`,
 		Description: "create ${out}",
 	}, "outDir")
 
 	aidlCppRule = pctx.StaticRule("aidlCppRule", blueprint.RuleParams{
 		Command: `mkdir -p "${headerDir}" && ` +
-			`${aidlCmd} --lang=${lang} ${optionalFlags} --structured --ninja -d ${out}.d ` +
-			`-h ${headerDir} -o ${outDir} ${imports} ${in}`,
+			`mkdir -p "${outDir}/staging" && ` +
+			`mkdir -p "${headerDir}/staging" && ` +
+			`${aidlCmd} --lang=${lang} ${optionalFlags} --structured --ninja -d ${outStagingFile}.d ` +
+			`-h ${headerDir}/staging -o ${outDir}/staging ${imports} ${in} && ` +
+			`rsync --checksum ${outStagingFile}.d ${out}.d && ` +
+			`rsync --checksum ${outStagingFile} ${out} && ` +
+			`( [ -z "${stagingHeaders}" ] || rsync --checksum ${stagingHeaders} ${fullHeaderDir} ) && ` +
+			`sed -i 's/\/gen\/staging\//\/gen\//g' ${out}.d && ` +
+			`rm ${outStagingFile} ${outStagingFile}.d ${stagingHeaders}`,
 		Depfile:     "${out}.d",
 		Deps:        blueprint.DepsGCC,
 		CommandDeps: []string{"${aidlCmd}"},
+		Restat:      true,
 		Description: "AIDL ${lang} ${in}",
-	}, "imports", "lang", "headerDir", "outDir", "optionalFlags")
+	}, "imports", "lang", "headerDir", "outDir", "optionalFlags", "stagingHeaders", "outStagingFile",
+		"fullHeaderDir")
 
 	aidlJavaRule = pctx.StaticRule("aidlJavaRule", blueprint.RuleParams{
 		Command: `${aidlCmd} --lang=java ${optionalFlags} --structured --ninja -d ${out}.d ` +
@@ -49,6 +57,7 @@
 		Depfile:     "${out}.d",
 		Deps:        blueprint.DepsGCC,
 		CommandDeps: []string{"${aidlCmd}"},
+		Restat:      true,
 		Description: "AIDL Java ${in}",
 	}, "imports", "outDir", "optionalFlags")
 
@@ -58,6 +67,7 @@
 		Depfile:     "${out}.d",
 		Deps:        blueprint.DepsGCC,
 		CommandDeps: []string{"${aidlCmd}"},
+		Restat:      true,
 		Description: "AIDL Rust ${in}",
 	}, "imports", "outDir", "optionalFlags")
 )
@@ -169,6 +179,7 @@
 		ext = "cpp"
 	}
 	outFile := android.PathForModuleGen(ctx, pathtools.ReplaceExtension(relPath, ext))
+	outStagingFile := android.PathForModuleGen(ctx, pathtools.ReplaceExtension("staging/"+relPath, ext))
 	implicits := g.implicitInputs
 
 	optionalFlags := append([]string{}, g.properties.Flags...)
@@ -251,10 +262,15 @@
 			prefix = "aidl"
 		}
 
+		var stagingHeaders []string
+		var fullHeaderDir = g.genHeaderDir.Join(ctx, prefix, packagePath)
 		if g.properties.Lang != langCppAnalyzer {
 			headers = append(headers, g.genHeaderDir.Join(ctx, prefix, packagePath, typeName+".h"))
+			stagingHeaders = append(stagingHeaders, g.genHeaderDir.Join(ctx, "staging/"+prefix, packagePath, typeName+".h").String())
 			headers = append(headers, g.genHeaderDir.Join(ctx, prefix, packagePath, "Bp"+baseName+".h"))
+			stagingHeaders = append(stagingHeaders, g.genHeaderDir.Join(ctx, "staging/"+prefix, packagePath, "Bp"+baseName+".h").String())
 			headers = append(headers, g.genHeaderDir.Join(ctx, prefix, packagePath, "Bn"+baseName+".h"))
+			stagingHeaders = append(stagingHeaders, g.genHeaderDir.Join(ctx, "staging/"+prefix, packagePath, "Bn"+baseName+".h").String())
 		}
 
 		if g.properties.GenLog {
@@ -273,11 +289,14 @@
 			Output:          outFile,
 			ImplicitOutputs: headers,
 			Args: map[string]string{
-				"imports":       g.importFlags,
-				"lang":          aidlLang,
-				"headerDir":     g.genHeaderDir.String(),
-				"outDir":        g.genOutDir.String(),
-				"optionalFlags": strings.Join(optionalFlags, " "),
+				"imports":        g.importFlags,
+				"lang":           aidlLang,
+				"headerDir":      g.genHeaderDir.String(),
+				"fullHeaderDir":  fullHeaderDir.String(),
+				"outDir":         g.genOutDir.String(),
+				"outStagingFile": outStagingFile.String(),
+				"optionalFlags":  strings.Join(optionalFlags, " "),
+				"stagingHeaders": strings.Join(stagingHeaders, " "),
 			},
 		})
 	}
diff --git a/build/aidl_interface.go b/build/aidl_interface.go
index 1f0fef8..f0330a9 100644
--- a/build/aidl_interface.go
+++ b/build/aidl_interface.go
@@ -426,7 +426,7 @@
 	// doesn't create the API dump and require it to be updated. Default is false.
 	Unstable *bool
 
-	// Optional flags to be passed to the AIDL compiler. e.g. "-Weverything"
+	// Optional flags to be passed to the AIDL compiler for diagnostics. e.g. "-Weverything"
 	Flags []string
 
 	// --dumpapi options
@@ -790,6 +790,14 @@
 	mctx.PropertyErrorf("vndk_use_version", "Specified version %q does not exist", *i.properties.Vndk_use_version)
 }
 
+func (i *aidlInterface) checkFlags(mctx android.DefaultableHookContext) {
+	for _, flag := range i.properties.Flags {
+		if !strings.HasPrefix(flag, "-W") {
+			mctx.PropertyErrorf("flags", "Unexpected flag type '%s'. Only flags starting with '-W' for diagnostics are supported.", flag)
+		}
+	}
+}
+
 func (i *aidlInterface) nextVersion() string {
 	if proptools.Bool(i.properties.Unstable) {
 		return ""
@@ -897,6 +905,7 @@
 	i.checkVersions(mctx)
 	i.checkVndkUseVersion(mctx)
 	i.checkGenTrace(mctx)
+	i.checkFlags(mctx)
 
 	if mctx.Failed() {
 		return
@@ -1212,19 +1221,19 @@
 		javaConfig = &javaConfigAttributes{}
 		javaConfig.Enabled = true
 		javaConfig.Min_sdk_version = i.minSdkVersion(langJava)
-		javaConfig.Tags = android.ConvertApexAvailableToTags(i.properties.Backend.Java.Apex_available)
+		javaConfig.Tags = android.ConvertApexAvailableToTagsWithoutTestApexes(ctx, i.properties.Backend.Java.Apex_available)
 	}
 	if i.shouldGenerateCppBackend() {
 		cppConfig = &cppConfigAttributes{}
 		cppConfig.Enabled = true
 		cppConfig.Min_sdk_version = i.minSdkVersion(langCpp)
-		cppConfig.Tags = android.ConvertApexAvailableToTags(i.properties.Backend.Cpp.Apex_available)
+		cppConfig.Tags = android.ConvertApexAvailableToTagsWithoutTestApexes(ctx, i.properties.Backend.Cpp.Apex_available)
 	}
 	if i.shouldGenerateNdkBackend() {
 		ndkConfig = &ndkConfigAttributes{}
 		ndkConfig.Enabled = true
 		ndkConfig.Min_sdk_version = i.minSdkVersion(langNdk)
-		ndkConfig.Tags = android.ConvertApexAvailableToTags(i.properties.Backend.Ndk.Apex_available)
+		ndkConfig.Tags = android.ConvertApexAvailableToTagsWithoutTestApexes(ctx, i.properties.Backend.Ndk.Apex_available)
 	}
 
 	imports := getBazelLabelListForImports(ctx, i.properties.Imports)
diff --git a/build/aidl_interface_backends.go b/build/aidl_interface_backends.go
index de3b14a..6fc0df3 100644
--- a/build/aidl_interface_backends.go
+++ b/build/aidl_interface_backends.go
@@ -417,7 +417,7 @@
 	versionedRustName := fixRustName(i.versionedName(version))
 	rustCrateName := fixRustName(i.ModuleBase.Name())
 
-	mctx.CreateModule(wrapLibraryFactory(aidlRustLibraryFactory), &rustProperties{
+	mctx.CreateModule(wrapLibraryFactory(func() android.Module { return aidlRustLibraryFactory(i.ModuleBase.SocSpecific()) }), &rustProperties{
 		Name:              proptools.StringPtr(rustModuleGen),
 		Crate_name:        rustCrateName,
 		Stem:              proptools.StringPtr("lib" + versionedRustName),
@@ -483,10 +483,11 @@
 }
 
 func (i *aidlInterface) flagsForAidlGenRule(version string) (flags []string) {
-	flags = append(flags, i.properties.Flags...)
-	// For ToT, turn on "-Weverything" (enable all warnings)
-	if version == i.nextVersion() {
+	// For the latest unfrozen version of an interface we turn on all warnings and use
+	// all flags supplied by the 'flags' field in the aidl_interface module
+	if version == i.nextVersion() && !i.isFrozen() {
 		flags = append(flags, "-Weverything -Wno-missing-permission-annotation")
+		flags = append(flags, i.properties.Flags...)
 	}
 	return
 }
diff --git a/build/aidl_interface_bp2build_test.go b/build/aidl_interface_bp2build_test.go
index b60c5dc..65cb3b2 100644
--- a/build/aidl_interface_bp2build_test.go
+++ b/build/aidl_interface_bp2build_test.go
@@ -54,7 +54,7 @@
 			}
 			aidl_interface {
 				name: "aidl-interface1",
-				flags: ["--flag1"],
+				flags: ["-Wsomething"],
 				imports: [
 				"aidl-interface-import-V1",
 				],
@@ -99,7 +99,7 @@
         "enabled": True,
     }`,
 				"deps":  `[":aidl-interface-headers"]`,
-				"flags": `["--flag1"]`,
+				"flags": `["-Wsomething"]`,
 				"versions_with_info": `[
         {
         "deps": [":aidl-interface-import-V1"],
diff --git a/build/aidl_rust_glue.py b/build/aidl_rust_glue.py
index a110618..c06790d 100755
--- a/build/aidl_rust_glue.py
+++ b/build/aidl_rust_glue.py
@@ -71,8 +71,6 @@
         node.files.append((in_name, inp))
 
   with open(output, "w") as lib_rs_file:
-    # Enable custom attributes for #![rustfmt::skip]
-    lib_rs_file.write("#![feature(custom_inner_attributes)]\n")
     lib_rs_file.write("#![allow(non_snake_case)]\n")
     lib_rs_file.write("#![allow(missing_docs)]\n")
     lib_rs_file.write("pub use binder;\n")
@@ -88,7 +86,8 @@
     lib_rs_file.write("}\n")
 
 def execute():
-  parser = argparse.ArgumentParser(description='Generate the top-level lib.rs.')
+  parser = argparse.ArgumentParser(description='Generate the top-level lib.rs.',
+                                   fromfile_prefix_chars='@')
   parser.add_argument('output', help='Path to output .rs file')
   parser.add_argument('root', help='Common ancestor of all input files')
   parser.add_argument('inputs', nargs='+', help='Input .rs files')
diff --git a/build/aidl_rust_source_provider.go b/build/aidl_rust_source_provider.go
index 1b91600..b8e6200 100644
--- a/build/aidl_rust_source_provider.go
+++ b/build/aidl_rust_source_provider.go
@@ -114,12 +114,12 @@
 		})
 }
 
-func aidlRustLibraryFactory() android.Module {
+func aidlRustLibraryFactory(rlibOnly bool) android.Module {
 	sourceProvider := &aidlRustSourceProvider{
 		BaseSourceProvider: rust.NewSourceProvider(),
 		properties:         aidlRustSourceProviderProperties{},
 	}
 
-	module := rust.NewSourceProviderModule(android.HostAndDeviceSupported, sourceProvider, false, false)
+	module := rust.NewSourceProviderModule(android.HostAndDeviceSupported, sourceProvider, false, rlibOnly)
 	return module.Init()
 }
diff --git a/diagnostics.cpp b/diagnostics.cpp
index d3f04b5..5c51f03 100644
--- a/diagnostics.cpp
+++ b/diagnostics.cpp
@@ -50,6 +50,12 @@
   return kDiagnosticsNames.at(id);
 }
 
+static std::string ToUpper(const std::string& name) {
+  std::string nameCopy(name);
+  for (auto& c : nameCopy) c = std::toupper(c);
+  return nameCopy;
+}
+
 class DiagnosticsContext {
  public:
   DiagnosticsContext(DiagnosticMapping mapping) : mapping_({std::move(mapping)}) {}
@@ -160,10 +166,6 @@
           << "Constants should be named in upper case: " << c.GetName();
     }
   }
-  static std::string ToUpper(std::string name) {
-    for (auto& c : name) c = std::toupper(c);
-    return name;
-  }
 };
 
 struct DiagnoseExplicitDefault : DiagnosticsVisitor {
@@ -222,6 +224,31 @@
   }
 };
 
+struct DiagnoseRedundantOneway : DiagnosticsVisitor {
+  DiagnoseRedundantOneway(DiagnosticsContext& diag) : DiagnosticsVisitor(diag) {}
+  void Visit(const AidlInterface& i) override {
+    if (i.HasOnewayAnnotation()) {
+      for (const auto& m : i.GetMethods()) {
+        if (!m->IsUserDefined()) continue;
+        if (Suppressed(*m)) continue;
+        if (m->HasOnewayAnnotation()) {
+          diag.Report(i.GetLocation(), DiagnosticID::redundant_oneway)
+              << "The interface '" << i.GetName()
+              << "' is oneway. Redundant oneway annotation for method '" << m->GetName() << "'.";
+        }
+      }
+    }
+  }
+  bool Suppressed(const AidlMethod& m) const {
+    for (const auto& w : m.GetType().SuppressWarnings()) {
+      if (w == to_string(DiagnosticID::redundant_oneway)) {
+        return true;
+      }
+    }
+    return false;
+  }
+};
+
 struct DiagnoseOutArray : DiagnosticsVisitor {
   DiagnoseOutArray(DiagnosticsContext& diag) : DiagnosticsVisitor(diag) {}
   void Visit(const AidlMethod& m) override {
@@ -336,6 +363,88 @@
   }
 };
 
+struct DiagnoseRedundantNames : DiagnosticsVisitor {
+  DiagnoseRedundantNames(DiagnosticsContext& diag) : DiagnosticsVisitor(diag) {}
+
+  // tokenize the name with either capital letters or '_' being the delimiters
+  static std::vector<std::string> TokenizeName(const std::string& name) {
+    // if a name is all capitals with no '_', then we don't want to tokenize it.
+    if (std::all_of(name.begin(), name.end(), [](unsigned char c) { return isupper(c); })) {
+      return {name};
+    }
+    // if a name has an `_` in it, it will be tokenized based on '_',
+    // otherwise based on capital letters
+    if (name.find('_') != std::string::npos) {
+      return base::Tokenize(name, "_");
+    }
+
+    std::vector<std::string> tokens;
+    size_t size = name.size();
+    std::string tmp{name.front()};
+    // Skip the first character to avoid an empty substring for common cases
+    for (size_t i = 1; i < size; i++) {
+      if (std::isupper(name[i])) {
+        tokens.push_back(tmp);
+        tmp.clear();
+        // This uppercase letter belongs to the next token
+        tmp += name[i];
+      } else {
+        tmp += name[i];
+      }
+    }
+
+    if (!tmp.empty()) tokens.push_back(tmp);
+
+    return tokens;
+  }
+
+  void Visit(const AidlEnumDeclaration& e) override {
+    const std::vector<std::string> parent = TokenizeName(e.GetName());
+    for (const auto& enumerator : e.GetEnumerators()) {
+      const std::vector<std::string> child = TokenizeName(enumerator->GetName());
+      for (const auto& parentSubStr : parent) {
+        for (const auto& childSubStr : child) {
+          if (ToUpper(parentSubStr) == ToUpper(childSubStr)) {
+            diag.Report(e.GetLocation(), DiagnosticID::redundant_name)
+                << "The enumerator '" << enumerator->GetName() << "' has a redundant substring '"
+                << childSubStr << "' being defined in '" << e.GetName() << "'";
+          }
+        }
+      }
+    }
+  }
+
+  void CheckConstantDeclarations(
+      const std::string& name,
+      const std::vector<std::unique_ptr<AidlConstantDeclaration>>& consts) {
+    const std::vector<std::string> parent = TokenizeName(name);
+    for (const auto& member : consts) {
+      const std::vector<std::string> child = TokenizeName(member->GetName());
+      for (const auto& parentSubStr : parent) {
+        for (const auto& childSubStr : child) {
+          if (ToUpper(parentSubStr) == ToUpper(childSubStr)) {
+            diag.Report(member->GetLocation(), DiagnosticID::redundant_name)
+                << "The constant '" << member->GetName() << "' has a redundant substring '"
+                << childSubStr << "' being defined in '" << name << "'";
+          }
+        }
+      }
+    }
+  }
+
+  void Visit(const AidlInterface& t) override {
+    CheckConstantDeclarations(t.GetName(), t.GetConstantDeclarations());
+  }
+
+  void Visit(const AidlUnionDecl& t) override {
+    CheckConstantDeclarations(t.GetName(), t.GetConstantDeclarations());
+  }
+
+  void Visit(const AidlStructuredParcelable& t) override {
+    CheckConstantDeclarations(t.GetName(), t.GetConstantDeclarations());
+  }
+};
+
 bool Diagnose(const AidlDocument& doc, const DiagnosticMapping& mapping) {
   DiagnosticsContext diag(mapping);
 
@@ -350,6 +459,8 @@
   DiagnoseImports{diag}.Check(doc);
   DiagnoseUntypedCollection{diag}.Check(doc);
   DiagnosePermissionAnnotations{diag}.Check(doc);
+  DiagnoseRedundantNames{diag}.Check(doc);
+  DiagnoseRedundantOneway{diag}.Check(doc);
 
   return diag.ErrorCount() == 0;
 }
diff --git a/diagnostics.inc b/diagnostics.inc
index 6a0570a..9abdee8 100644
--- a/diagnostics.inc
+++ b/diagnostics.inc
@@ -11,3 +11,5 @@
 DIAG(unique_import, "unique-import", false)
 DIAG(unknown_warning, "unknown-warning", false)
 DIAG(untyped_collection, "untyped-collection", false)
+DIAG(redundant_name, "redundant-name", false)
+DIAG(redundant_oneway, "redundant-oneway", false)
diff --git a/diagnostics_unittest.cpp b/diagnostics_unittest.cpp
index 3a45d09..feb8189 100644
--- a/diagnostics_unittest.cpp
+++ b/diagnostics_unittest.cpp
@@ -157,6 +157,24 @@
   });
 }
 
+TEST_F(DiagnosticsTest, RedundantOnewayMethodAnnotationInOnewayInterface) {
+  expect_diagnostic = DiagnosticID::redundant_oneway;
+  ParseFiles({
+      {"IFoo.aidl", "oneway interface IFoo { oneway void foo(int a); }"},
+  });
+}
+
+TEST_F(DiagnosticsTest, RedundantOnewayMethodSuppressedAtMethod) {
+  enable_diagnostic = DiagnosticID::redundant_oneway;
+  expect_diagnostic = {};
+  ParseFiles({
+      {"IFoo.aidl",
+       "oneway interface IFoo {\n"
+       "  @SuppressWarnings(value={\"redundant-oneway\"}) oneway void bar();\n"
+       "}"},
+  });
+}
+
 TEST_F(DiagnosticsTest, ArraysAsOutputParametersConsideredHarmful) {
   expect_diagnostic = DiagnosticID::out_array;
   ParseFiles({
@@ -281,3 +299,55 @@
   expect_diagnostic = {};
   ParseFiles({{"IFoo.aidl", "@EnforcePermission(\"INTERNET\") interface IFoo { void food(); }"}});
 }
+
+TEST_F(DiagnosticsTest, RedundantPrefixConstantInterface) {
+  enable_diagnostic = DiagnosticID::redundant_name;
+  expect_diagnostic = DiagnosticID::redundant_name;
+  ParseFiles({{"SomethingStatus.aidl", "interface SomethingStatus { const int STATUS_ONE = 1; }"}});
+}
+
+TEST_F(DiagnosticsTest, RedundantPrefixConstantParcelable) {
+  enable_diagnostic = DiagnosticID::redundant_name;
+  expect_diagnostic = DiagnosticID::redundant_name;
+  ParseFiles(
+      {{"SomethingStatus.aidl", "parcelable SomethingStatus { const int STATUS_ONE = 1; }"}});
+}
+
+TEST_F(DiagnosticsTest, RedundantSuffixConstantParcelable) {
+  enable_diagnostic = DiagnosticID::redundant_name;
+  expect_diagnostic = DiagnosticID::redundant_name;
+  ParseFiles(
+      {{"SomethingStatus.aidl", "parcelable SomethingStatus { const int ONE_STATUS = 1; }"}});
+}
+
+TEST_F(DiagnosticsTest, RedundantSuffixConstantParcelable2) {
+  enable_diagnostic = DiagnosticID::redundant_name;
+  expect_diagnostic = DiagnosticID::redundant_name;
+  ParseFiles(
+      {{"SomethingStatus.aidl", "parcelable SomethingStatus { const int ONE_SOMETHING = 1; }"}});
+}
+
+TEST_F(DiagnosticsTest, RedundantConstantUnion) {
+  enable_diagnostic = DiagnosticID::redundant_name;
+  expect_diagnostic = DiagnosticID::redundant_name;
+  ParseFiles({{"SomethingStatus.aidl",
+               "union SomethingStatus { const int ONE_SOMETHING = 1; int a; int b;}"}});
+}
+
+TEST_F(DiagnosticsTest, RedundantPrefixEnum) {
+  enable_diagnostic = DiagnosticID::redundant_name;
+  expect_diagnostic = DiagnosticID::redundant_name;
+  ParseFiles({{"SomethingStatus.aidl", "enum SomethingStatus { STATUS_ONE = 1, }"}});
+}
+
+TEST_F(DiagnosticsTest, RedundantSuffixEnum) {
+  enable_diagnostic = DiagnosticID::redundant_name;
+  expect_diagnostic = DiagnosticID::redundant_name;
+  ParseFiles({{"SomethingStatus.aidl", "enum SomethingStatus { ONE_STATUS = 1, }"}});
+}
+
+TEST_F(DiagnosticsTest, RedundantSuffixEnum2) {
+  enable_diagnostic = DiagnosticID::redundant_name;
+  expect_diagnostic = DiagnosticID::redundant_name;
+  ParseFiles({{"SomethingStatus.aidl", "enum SomethingStatus { ONE_SOMETHING = 1, }"}});
+}
diff --git a/generate_java_binder.cpp b/generate_java_binder.cpp
index c631e34..6dd5935 100644
--- a/generate_java_binder.cpp
+++ b/generate_java_binder.cpp
@@ -85,7 +85,7 @@
   std::shared_ptr<Variable> transact_data;
   std::shared_ptr<Variable> transact_reply;
   std::shared_ptr<Variable> transact_flags;
-  std::shared_ptr<SwitchStatement> transact_switch_meta;
+  std::vector<std::shared_ptr<IfStatement>> transact_if_statements_meta;
   std::shared_ptr<SwitchStatement> transact_switch_user;
   std::shared_ptr<StatementBlock> transact_statements;
   std::shared_ptr<SwitchStatement> code_to_method_name_switch;
@@ -181,7 +181,6 @@
   transact_statements = onTransact->statements;
   onTransact->exceptions.push_back("android.os.RemoteException");
   this->elements.push_back(onTransact);
-  this->transact_switch_meta = std::make_shared<SwitchStatement>(this->transact_code);
   this->transact_switch_user = std::make_shared<SwitchStatement>(this->transact_code);
 }
 
@@ -210,8 +209,22 @@
     transact_statements->Add(ifStatement);
   }
 
+  // Build the if/else chain for the meta methods. There at most 3 different
+  // statements so if/else is more efficient than a switch statement.
   // Meta transactions are looked up prior to user-defined transactions.
-  transact_statements->Add(this->transact_switch_meta);
+  AIDL_FATAL_IF(this->transact_if_statements_meta.size() == 0, AIDL_LOCATION_HERE)
+      << "Expecting to have meta methods and found none.";
+  AIDL_FATAL_IF(this->transact_if_statements_meta.size() > 3, AIDL_LOCATION_HERE)
+      << "Expecting to have at most 3 meta methods and found "
+      << this->transact_if_statements_meta.size();
+  auto ifStatement = this->transact_if_statements_meta[0];
+  std::shared_ptr<IfStatement> currentIfStatement = ifStatement;
+  for (size_t i = 1; i < transact_if_statements_meta.size(); i++) {
+    currentIfStatement->elseif = this->transact_if_statements_meta[i];
+    currentIfStatement = currentIfStatement->elseif;
+  }
+
+  transact_statements->Add(ifStatement);
   transact_statements->Add(this->transact_switch_user);
 
   // getTransactionName
@@ -472,7 +485,26 @@
 // Visitor for the permission declared in the @EnforcePermission annotation.
 class PermissionVisitor {
  public:
-  PermissionVisitor(CodeWriter* code) : code_(code) {}
+  PermissionVisitor(CodeWriter* code, const AidlMethod& method) : code_(code), method_(method) {}
+
+  ~PermissionVisitor() {
+    code_->Dedent();
+    *code_ << "}\n";
+  }
+
+  string Credentials() const { return "getCallingPid(), getCallingUid()"; }
+
+  void Prologue() {
+    *code_ << "/** Helper method to enforce permissions for " << method_.GetName() << " */\n";
+    *code_ << "protected void " << method_.GetName() << "_enforcePermission() "
+           << "throws SecurityException {\n";
+    code_->Indent();
+  }
+
+  void AddStaticArrayPermissions(const std::vector<std::string>& permissions) {
+    *code_ << "static final String[] PERMISSIONS_" << method_.GetName() << " = {"
+           << Join(permissions, ", ") << "};\n";
+  }
 
   void operator()(const perm::AllOf& quantifier) {
     std::vector<std::string> permissions;
@@ -480,8 +512,10 @@
     for (auto const& permission : quantifier.operands) {
       permissions.push_back(android::aidl::perm::JavaFullName(permission));
     }
-    *code_ << "mEnforcer.enforcePermissionAllOf(new String[]{" << Join(permissions, ", ")
-           << "}, source);\n";
+    AddStaticArrayPermissions(permissions);
+    Prologue();
+    *code_ << "mEnforcer.enforcePermissionAllOf(PERMISSIONS_" << method_.GetName() << ", "
+           << Credentials() << ");\n";
   }
 
   void operator()(const perm::AnyOf& quantifier) {
@@ -490,47 +524,33 @@
     for (auto const& permission : quantifier.operands) {
       permissions.push_back(android::aidl::perm::JavaFullName(permission));
     }
-    *code_ << "mEnforcer.enforcePermissionAnyOf(new String[]{" << Join(permissions, ", ")
-           << "}, source);\n";
+    AddStaticArrayPermissions(permissions);
+    Prologue();
+    *code_ << "mEnforcer.enforcePermissionAnyOf(PERMISSIONS_" << method_.GetName() << ", "
+           << Credentials() << ");\n";
   }
 
   void operator()(const std::string& permission) {
     auto permissionName = android::aidl::perm::JavaFullName(permission);
-    *code_ << "mEnforcer.enforcePermission(" << permissionName << ", source);\n";
+    Prologue();
+    *code_ << "mEnforcer.enforcePermission(" << permissionName << ", " << Credentials() << ");\n";
   }
 
  private:
   CodeWriter* code_;
+  const AidlMethod& method_;
 };
 
 static void GeneratePermissionMethod(const AidlInterface& iface, const AidlMethod& method,
                                      const std::shared_ptr<Class>& addTo) {
   string code;
   CodeWriterPtr writer = CodeWriter::ForString(&code);
-  *writer << "/** Helper method to enforce permissions for " << method.GetName() << " */\n";
-
-  auto has_attribution_source =
-      std::any_of(method.GetArguments().begin(), method.GetArguments().end(), [](const auto& arg) {
-        return arg->GetType().GetName() == "android.content.AttributionSource";
-      });
-
-  *writer << "protected void " << method.GetName() << "_enforcePermission("
-          << (has_attribution_source ? "android.content.AttributionSource source" : "")
-          << ") throws SecurityException {\n";
-  writer->Indent();
-
-  if (!has_attribution_source) {
-    *writer << "android.content.AttributionSource source = "
-               "new android.content.AttributionSource(getCallingUid(), null, null);\n";
-  }
 
   if (auto ifacePermExpr = iface.EnforceExpression(); ifacePermExpr) {
-    std::visit(PermissionVisitor(writer.get()), *ifacePermExpr.get());
+    std::visit(PermissionVisitor(writer.get(), method), *ifacePermExpr.get());
   } else if (auto methodPermExpr = method.GetType().EnforceExpression(); methodPermExpr) {
-    std::visit(PermissionVisitor(writer.get()), *methodPermExpr.get());
+    std::visit(PermissionVisitor(writer.get(), method), *methodPermExpr.get());
   }
-  writer->Dedent();
-  *writer << "}\n";
   writer->Close();
   addTo->elements.push_back(std::make_shared<LiteralClassElement>(code));
 }
@@ -918,22 +938,24 @@
     }
   } else {
     if (method.GetName() == kGetInterfaceVersion && options.Version() > 0) {
-      auto c = std::make_shared<Case>(transactCodeName);
+      auto ifStatement = std::make_shared<IfStatement>();
+      ifStatement->expression = std::make_shared<LiteralExpression>("code == " + transactCodeName);
       std::ostringstream code;
       code << "reply.writeNoException();\n"
            << "reply.writeInt(" << kGetInterfaceVersion << "());\n"
            << "return true;\n";
-      c->statements->Add(std::make_shared<LiteralStatement>(code.str()));
-      stubClass->transact_switch_meta->cases.push_back(c);
+      ifStatement->statements->Add(std::make_shared<LiteralStatement>(code.str()));
+      stubClass->transact_if_statements_meta.push_back(ifStatement);
     }
     if (method.GetName() == kGetInterfaceHash && !options.Hash().empty()) {
-      auto c = std::make_shared<Case>(transactCodeName);
+      auto ifStatement = std::make_shared<IfStatement>();
+      ifStatement->expression = std::make_shared<LiteralExpression>("code == " + transactCodeName);
       std::ostringstream code;
       code << "reply.writeNoException();\n"
            << "reply.writeString(" << kGetInterfaceHash << "());\n"
            << "return true;\n";
-      c->statements->Add(std::make_shared<LiteralStatement>(code.str()));
-      stubClass->transact_switch_meta->cases.push_back(c);
+      ifStatement->statements->Add(std::make_shared<LiteralStatement>(code.str()));
+      stubClass->transact_if_statements_meta.push_back(ifStatement);
     }
   }
 
@@ -1021,12 +1043,13 @@
                                          Class* interface, std::shared_ptr<StubClass> stub,
                                          std::shared_ptr<ProxyClass> proxy) {
   // the interface descriptor transaction handler
-  auto c = std::make_shared<Case>("INTERFACE_TRANSACTION");
-  c->statements->Add(std::make_shared<MethodCall>(
+  auto ifStatement = std::make_shared<IfStatement>();
+  ifStatement->expression = std::make_shared<LiteralExpression>("code == INTERFACE_TRANSACTION");
+  ifStatement->statements->Add(std::make_shared<MethodCall>(
       stub->transact_reply, "writeString",
       std::vector<std::shared_ptr<Expression>>{stub->GetTransactDescriptor(nullptr)}));
-  c->statements->Add(std::make_shared<ReturnStatement>(TRUE_VALUE));
-  stub->transact_switch_meta->cases.push_back(c);
+  ifStatement->statements->Add(std::make_shared<ReturnStatement>(TRUE_VALUE));
+  stub->transact_if_statements_meta.push_back(ifStatement);
 
   // and the proxy-side method returning the descriptor directly
   auto getDesc = std::make_shared<Method>();
diff --git a/generate_rust.cpp b/generate_rust.cpp
index 17beb36..93c9536 100644
--- a/generate_rust.cpp
+++ b/generate_rust.cpp
@@ -1229,7 +1229,7 @@
   // Unsafe code should only be allowed in libbinder_rs.
   *code_writer << "#![forbid(unsafe_code)]\n";
   // Disable rustfmt on auto-generated files, including the golden outputs
-  *code_writer << "#![rustfmt::skip]\n";
+  *code_writer << "#![cfg_attr(rustfmt, rustfmt_skip)]\n";
   GenerateClass(code_writer.get(), defined_type, types, options);
   GenerateMangledAliases(*code_writer, defined_type);
 
diff --git a/tests/aidl_test_client_ndk_strings_test.cpp b/tests/aidl_test_client_ndk_strings_test.cpp
index a9873bb..782357c 100644
--- a/tests/aidl_test_client_ndk_strings_test.cpp
+++ b/tests/aidl_test_client_ndk_strings_test.cpp
@@ -50,7 +50,7 @@
       std::string("\0\0", 2),
       // Similarly, the utf8 encodings of the small letter yee and euro sign.
       std::string("\xF0\x90\x90\xB7\xE2\x82\xAC"),
-      ITestService::STRING_TEST_CONSTANT_UTF8,
+      ITestService::STRING_CONSTANT_UTF8,
   };
 
   for (const auto& input : utf8_inputs) {
diff --git a/tests/aidl_test_client_primitives.cpp b/tests/aidl_test_client_primitives.cpp
index 040804d..1544f3b 100644
--- a/tests/aidl_test_client_primitives.cpp
+++ b/tests/aidl_test_client_primitives.cpp
@@ -96,7 +96,7 @@
 }
 
 TEST_F(AidlPrimitiveTest, byteConstants) {
-  constexpr int8_t consts[] = {ITestService::BYTE_TEST_CONSTANT};
+  constexpr int8_t consts[] = {ITestService::BYTE_CONSTANT};
   for (auto sent : consts) {
     DoTest(&ITestService::RepeatByte, sent);
   }
@@ -104,17 +104,17 @@
 
 TEST_F(AidlPrimitiveTest, intConstants) {
   constexpr int32_t consts[] = {
-      ITestService::TEST_CONSTANT,   ITestService::TEST_CONSTANT2,  ITestService::TEST_CONSTANT3,
-      ITestService::TEST_CONSTANT4,  ITestService::TEST_CONSTANT5,  ITestService::TEST_CONSTANT6,
-      ITestService::TEST_CONSTANT7,  ITestService::TEST_CONSTANT8,  ITestService::TEST_CONSTANT9,
-      ITestService::TEST_CONSTANT10, ITestService::TEST_CONSTANT11, ITestService::TEST_CONSTANT12};
+      ITestService::CONSTANT,   ITestService::CONSTANT2,  ITestService::CONSTANT3,
+      ITestService::CONSTANT4,  ITestService::CONSTANT5,  ITestService::CONSTANT6,
+      ITestService::CONSTANT7,  ITestService::CONSTANT8,  ITestService::CONSTANT9,
+      ITestService::CONSTANT10, ITestService::CONSTANT11, ITestService::CONSTANT12};
   for (auto sent : consts) {
     DoTest(&ITestService::RepeatInt, sent);
   }
 }
 
 TEST_F(AidlPrimitiveTest, longConstants) {
-  constexpr int64_t consts[] = {ITestService::LONG_TEST_CONSTANT};
+  constexpr int64_t consts[] = {ITestService::LONG_CONSTANT};
   for (auto sent : consts) {
     DoTest(&ITestService::RepeatLong, sent);
   }
@@ -122,10 +122,9 @@
 
 TEST_F(AidlPrimitiveTest, floatConstants) {
   constexpr float consts[] = {
-      ITestService::FLOAT_TEST_CONSTANT,  ITestService::FLOAT_TEST_CONSTANT2,
-      ITestService::FLOAT_TEST_CONSTANT3, ITestService::FLOAT_TEST_CONSTANT4,
-      ITestService::FLOAT_TEST_CONSTANT5, ITestService::FLOAT_TEST_CONSTANT6,
-      ITestService::FLOAT_TEST_CONSTANT7,
+      ITestService::FLOAT_CONSTANT,  ITestService::FLOAT_CONSTANT2, ITestService::FLOAT_CONSTANT3,
+      ITestService::FLOAT_CONSTANT4, ITestService::FLOAT_CONSTANT5, ITestService::FLOAT_CONSTANT6,
+      ITestService::FLOAT_CONSTANT7,
   };
   for (auto sent : consts) {
     DoTest(&ITestService::RepeatFloat, sent);
@@ -134,11 +133,11 @@
 
 TEST_F(AidlPrimitiveTest, doubleConstants) {
   constexpr double consts[] = {
-      ITestService::DOUBLE_TEST_CONSTANT,  ITestService::DOUBLE_TEST_CONSTANT2,
-      ITestService::DOUBLE_TEST_CONSTANT3, ITestService::DOUBLE_TEST_CONSTANT4,
-      ITestService::DOUBLE_TEST_CONSTANT5, ITestService::DOUBLE_TEST_CONSTANT6,
-      ITestService::DOUBLE_TEST_CONSTANT7, ITestService::DOUBLE_TEST_CONSTANT8,
-      ITestService::DOUBLE_TEST_CONSTANT9,
+      ITestService::DOUBLE_CONSTANT,  ITestService::DOUBLE_CONSTANT2,
+      ITestService::DOUBLE_CONSTANT3, ITestService::DOUBLE_CONSTANT4,
+      ITestService::DOUBLE_CONSTANT5, ITestService::DOUBLE_CONSTANT6,
+      ITestService::DOUBLE_CONSTANT7, ITestService::DOUBLE_CONSTANT8,
+      ITestService::DOUBLE_CONSTANT9,
   };
   for (auto sent : consts) {
     DoTest(&ITestService::RepeatDouble, sent);
@@ -151,8 +150,8 @@
       // This is actually two unicode code points:
       //   U+10437: The 'small letter yee' character in the deseret alphabet
       //   U+20AC: A euro sign
-      String16("\xD8\x01\xDC\x37\x20\xAC"), ITestService::STRING_TEST_CONSTANT(),
-      ITestService::STRING_TEST_CONSTANT2()};
+      String16("\xD8\x01\xDC\x37\x20\xAC"), ITestService::STRING_CONSTANT(),
+      ITestService::STRING_CONSTANT2()};
   for (auto sent : strings) {
     DoTest(&ITestService::RepeatString, sent);
   }
@@ -361,8 +360,8 @@
   EXPECT_THAT(ITestService::A55, Eq(1));
   EXPECT_THAT(ITestService::A56, Eq(1));
   EXPECT_THAT(ITestService::A57, Eq(1));
-  EXPECT_THAT(ITestService::FLOAT_TEST_CONSTANT4, Eq(2.2f));
-  EXPECT_THAT(ITestService::FLOAT_TEST_CONSTANT5, Eq(-2.2f));
-  EXPECT_THAT(ITestService::DOUBLE_TEST_CONSTANT4, Eq(2.2));
-  EXPECT_THAT(ITestService::DOUBLE_TEST_CONSTANT5, Eq(-2.2));
+  EXPECT_THAT(ITestService::FLOAT_CONSTANT4, Eq(2.2f));
+  EXPECT_THAT(ITestService::FLOAT_CONSTANT5, Eq(-2.2f));
+  EXPECT_THAT(ITestService::DOUBLE_CONSTANT4, Eq(2.2));
+  EXPECT_THAT(ITestService::DOUBLE_CONSTANT5, Eq(-2.2));
 }
diff --git a/tests/aidl_test_client_utf8_strings.cpp b/tests/aidl_test_client_utf8_strings.cpp
index 6e3602b..8339137 100644
--- a/tests/aidl_test_client_utf8_strings.cpp
+++ b/tests/aidl_test_client_utf8_strings.cpp
@@ -42,7 +42,7 @@
       std::string("\0\0", 2),
       // Similarly, the utf8 encodings of the small letter yee and euro sign.
       std::string("\xF0\x90\x90\xB7\xE2\x82\xAC"),
-      ITestService::STRING_TEST_CONSTANT_UTF8(),
+      ITestService::STRING_CONSTANT_UTF8(),
   };
 
   for (const auto& input : utf8_inputs) {
diff --git a/tests/android/aidl/tests/ITestService.aidl b/tests/android/aidl/tests/ITestService.aidl
index fd8b6b5..d00df2c 100644
--- a/tests/android/aidl/tests/ITestService.aidl
+++ b/tests/android/aidl/tests/ITestService.aidl
@@ -50,44 +50,44 @@
     /**
      * const comment
      */
-    const int TEST_CONSTANT = 42;
-    const int TEST_CONSTANT2 = -42;
-    const int TEST_CONSTANT3 = +42;
-    const int TEST_CONSTANT4 = +4;
-    const int TEST_CONSTANT5 = -4;
-    const int TEST_CONSTANT6 = -0;
-    const int TEST_CONSTANT7 = +0;
-    const int TEST_CONSTANT8 = 0;
-    const int TEST_CONSTANT9 = 0x56;
-    const int TEST_CONSTANT10 = 0xa5;
-    const int TEST_CONSTANT11 = 0xFA;
-    const int TEST_CONSTANT12 = 0xffffffff;
+    const int CONSTANT = 42;
+    const int CONSTANT2 = -42;
+    const int CONSTANT3 = +42;
+    const int CONSTANT4 = +4;
+    const int CONSTANT5 = -4;
+    const int CONSTANT6 = -0;
+    const int CONSTANT7 = +0;
+    const int CONSTANT8 = 0;
+    const int CONSTANT9 = 0x56;
+    const int CONSTANT10 = 0xa5;
+    const int CONSTANT11 = 0xFA;
+    const int CONSTANT12 = 0xffffffff;
 
-    const byte BYTE_TEST_CONSTANT = 17;
-    const long LONG_TEST_CONSTANT = 1L << 40;
+    const byte BYTE_CONSTANT = 17;
+    const long LONG_CONSTANT = 1L << 40;
 
-    const String STRING_TEST_CONSTANT = "foo";
-    const String STRING_TEST_CONSTANT2 = "bar";
+    const String STRING_CONSTANT = "foo";
+    const String STRING_CONSTANT2 = "bar";
 
-    const float FLOAT_TEST_CONSTANT = 1.0f;
-    const float FLOAT_TEST_CONSTANT2 = -1.0f;
-    const float FLOAT_TEST_CONSTANT3 = +1.0f;
-    const float FLOAT_TEST_CONSTANT4 = +2.2f;
-    const float FLOAT_TEST_CONSTANT5 = -2.2f;
-    const float FLOAT_TEST_CONSTANT6 = -0.0f;
-    const float FLOAT_TEST_CONSTANT7 = +0.0f;
+    const float FLOAT_CONSTANT = 1.0f;
+    const float FLOAT_CONSTANT2 = -1.0f;
+    const float FLOAT_CONSTANT3 = +1.0f;
+    const float FLOAT_CONSTANT4 = +2.2f;
+    const float FLOAT_CONSTANT5 = -2.2f;
+    const float FLOAT_CONSTANT6 = -0.0f;
+    const float FLOAT_CONSTANT7 = +0.0f;
 
-    const double DOUBLE_TEST_CONSTANT = 1.0;
-    const double DOUBLE_TEST_CONSTANT2 = -1.0;
-    const double DOUBLE_TEST_CONSTANT3 = +1.0;
-    const double DOUBLE_TEST_CONSTANT4 = +2.2;
-    const double DOUBLE_TEST_CONSTANT5 = -2.2;
-    const double DOUBLE_TEST_CONSTANT6 = -0.0;
-    const double DOUBLE_TEST_CONSTANT7 = +0.0;
-    const double DOUBLE_TEST_CONSTANT8 = 1.1f;
-    const double DOUBLE_TEST_CONSTANT9 = -1.1f;
+    const double DOUBLE_CONSTANT = 1.0;
+    const double DOUBLE_CONSTANT2 = -1.0;
+    const double DOUBLE_CONSTANT3 = +1.0;
+    const double DOUBLE_CONSTANT4 = +2.2;
+    const double DOUBLE_CONSTANT5 = -2.2;
+    const double DOUBLE_CONSTANT6 = -0.0;
+    const double DOUBLE_CONSTANT7 = +0.0;
+    const double DOUBLE_CONSTANT8 = 1.1f;
+    const double DOUBLE_CONSTANT9 = -1.1f;
 
-    const @utf8InCpp String STRING_TEST_CONSTANT_UTF8 = "baz";
+    const @utf8InCpp String STRING_CONSTANT_UTF8 = "baz";
 
     // This is to emulate a method that is added after the service is implemented.
     // So the client cannot assume that a call to this method will be successful
diff --git a/tests/android/aidl/tests/permission/IProtected.aidl b/tests/android/aidl/tests/permission/IProtected.aidl
index d2fdba5..2504bc8 100644
--- a/tests/android/aidl/tests/permission/IProtected.aidl
+++ b/tests/android/aidl/tests/permission/IProtected.aidl
@@ -11,5 +11,7 @@
     void NonManifestPermission();
 
     // Used by the integration tests to dynamically set permissions that are considered granted.
-    @RequiresNoPermission void SetGranted(in List<String> permissions);
+    @RequiresNoPermission void Grant(in String permission);
+    @RequiresNoPermission void Revoke(in String permission);
+    @RequiresNoPermission void RevokeAll();
 }
diff --git a/tests/golden_output/aidl-test-fixedsizearray-java-source/gen/android/aidl/fixedsizearray/FixedSizeArrayExample.java b/tests/golden_output/aidl-test-fixedsizearray-java-source/gen/android/aidl/fixedsizearray/FixedSizeArrayExample.java
index a04eb16..54e451f 100644
--- a/tests/golden_output/aidl-test-fixedsizearray-java-source/gen/android/aidl/fixedsizearray/FixedSizeArrayExample.java
+++ b/tests/golden_output/aidl-test-fixedsizearray-java-source/gen/android/aidl/fixedsizearray/FixedSizeArrayExample.java
@@ -427,13 +427,9 @@
         if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
           data.enforceInterface(descriptor);
         }
-        switch (code)
-        {
-          case INTERFACE_TRANSACTION:
-          {
-            reply.writeString(descriptor);
-            return true;
-          }
+        if (code == INTERFACE_TRANSACTION) {
+          reply.writeString(descriptor);
+          return true;
         }
         switch (code)
         {
@@ -844,13 +840,9 @@
       @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
       {
         java.lang.String descriptor = DESCRIPTOR;
-        switch (code)
-        {
-          case INTERFACE_TRANSACTION:
-          {
-            reply.writeString(descriptor);
-            return true;
-          }
+        if (code == INTERFACE_TRANSACTION) {
+          reply.writeString(descriptor);
+          return true;
         }
         switch (code)
         {
diff --git a/tests/golden_output/aidl-test-fixedsizearray-rust-source/gen/android/aidl/fixedsizearray/FixedSizeArrayExample.rs b/tests/golden_output/aidl-test-fixedsizearray-rust-source/gen/android/aidl/fixedsizearray/FixedSizeArrayExample.rs
index 30fe659..0caeccb 100644
--- a/tests/golden_output/aidl-test-fixedsizearray-rust-source/gen/android/aidl/fixedsizearray/FixedSizeArrayExample.rs
+++ b/tests/golden_output/aidl-test-fixedsizearray-rust-source/gen/android/aidl/fixedsizearray/FixedSizeArrayExample.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug, PartialEq)]
 pub struct r#FixedSizeArrayExample {
   pub r#int2x3: [[i32; 3]; 2],
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp
index 4ca3e09..23ab5f4 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp
@@ -4,15 +4,15 @@
 namespace aidl {
 namespace tests {
 DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(TestService, "android.aidl.tests.ITestService")
-const ::android::String16& ITestService::STRING_TEST_CONSTANT() {
+const ::android::String16& ITestService::STRING_CONSTANT() {
   static const ::android::String16 value(::android::String16("foo"));
   return value;
 }
-const ::android::String16& ITestService::STRING_TEST_CONSTANT2() {
+const ::android::String16& ITestService::STRING_CONSTANT2() {
   static const ::android::String16 value(::android::String16("bar"));
   return value;
 }
-const ::std::string& ITestService::STRING_TEST_CONSTANT_UTF8() {
+const ::std::string& ITestService::STRING_CONSTANT_UTF8() {
   static const ::std::string value("baz");
   return value;
 }
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
index cbf30fc..3e14ce5 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
@@ -330,39 +330,39 @@
       return os.str();
     }
   };  // class CompilerChecks
-  enum : int32_t { TEST_CONSTANT = 42 };
-  enum : int32_t { TEST_CONSTANT2 = -42 };
-  enum : int32_t { TEST_CONSTANT3 = 42 };
-  enum : int32_t { TEST_CONSTANT4 = 4 };
-  enum : int32_t { TEST_CONSTANT5 = -4 };
-  enum : int32_t { TEST_CONSTANT6 = 0 };
-  enum : int32_t { TEST_CONSTANT7 = 0 };
-  enum : int32_t { TEST_CONSTANT8 = 0 };
-  enum : int32_t { TEST_CONSTANT9 = 86 };
-  enum : int32_t { TEST_CONSTANT10 = 165 };
-  enum : int32_t { TEST_CONSTANT11 = 250 };
-  enum : int32_t { TEST_CONSTANT12 = -1 };
-  enum : int8_t { BYTE_TEST_CONSTANT = 17 };
-  enum : int64_t { LONG_TEST_CONSTANT = 1099511627776L };
-  static const ::android::String16& STRING_TEST_CONSTANT();
-  static const ::android::String16& STRING_TEST_CONSTANT2();
-  static constexpr float FLOAT_TEST_CONSTANT = 1.000000f;
-  static constexpr float FLOAT_TEST_CONSTANT2 = -1.000000f;
-  static constexpr float FLOAT_TEST_CONSTANT3 = 1.000000f;
-  static constexpr float FLOAT_TEST_CONSTANT4 = 2.200000f;
-  static constexpr float FLOAT_TEST_CONSTANT5 = -2.200000f;
-  static constexpr float FLOAT_TEST_CONSTANT6 = -0.000000f;
-  static constexpr float FLOAT_TEST_CONSTANT7 = 0.000000f;
-  static constexpr double DOUBLE_TEST_CONSTANT = 1.000000;
-  static constexpr double DOUBLE_TEST_CONSTANT2 = -1.000000;
-  static constexpr double DOUBLE_TEST_CONSTANT3 = 1.000000;
-  static constexpr double DOUBLE_TEST_CONSTANT4 = 2.200000;
-  static constexpr double DOUBLE_TEST_CONSTANT5 = -2.200000;
-  static constexpr double DOUBLE_TEST_CONSTANT6 = -0.000000;
-  static constexpr double DOUBLE_TEST_CONSTANT7 = 0.000000;
-  static constexpr double DOUBLE_TEST_CONSTANT8 = 1.100000;
-  static constexpr double DOUBLE_TEST_CONSTANT9 = -1.100000;
-  static const ::std::string& STRING_TEST_CONSTANT_UTF8();
+  enum : int32_t { CONSTANT = 42 };
+  enum : int32_t { CONSTANT2 = -42 };
+  enum : int32_t { CONSTANT3 = 42 };
+  enum : int32_t { CONSTANT4 = 4 };
+  enum : int32_t { CONSTANT5 = -4 };
+  enum : int32_t { CONSTANT6 = 0 };
+  enum : int32_t { CONSTANT7 = 0 };
+  enum : int32_t { CONSTANT8 = 0 };
+  enum : int32_t { CONSTANT9 = 86 };
+  enum : int32_t { CONSTANT10 = 165 };
+  enum : int32_t { CONSTANT11 = 250 };
+  enum : int32_t { CONSTANT12 = -1 };
+  enum : int8_t { BYTE_CONSTANT = 17 };
+  enum : int64_t { LONG_CONSTANT = 1099511627776L };
+  static const ::android::String16& STRING_CONSTANT();
+  static const ::android::String16& STRING_CONSTANT2();
+  static constexpr float FLOAT_CONSTANT = 1.000000f;
+  static constexpr float FLOAT_CONSTANT2 = -1.000000f;
+  static constexpr float FLOAT_CONSTANT3 = 1.000000f;
+  static constexpr float FLOAT_CONSTANT4 = 2.200000f;
+  static constexpr float FLOAT_CONSTANT5 = -2.200000f;
+  static constexpr float FLOAT_CONSTANT6 = -0.000000f;
+  static constexpr float FLOAT_CONSTANT7 = 0.000000f;
+  static constexpr double DOUBLE_CONSTANT = 1.000000;
+  static constexpr double DOUBLE_CONSTANT2 = -1.000000;
+  static constexpr double DOUBLE_CONSTANT3 = 1.000000;
+  static constexpr double DOUBLE_CONSTANT4 = 2.200000;
+  static constexpr double DOUBLE_CONSTANT5 = -2.200000;
+  static constexpr double DOUBLE_CONSTANT6 = -0.000000;
+  static constexpr double DOUBLE_CONSTANT7 = 0.000000;
+  static constexpr double DOUBLE_CONSTANT8 = 1.100000;
+  static constexpr double DOUBLE_CONSTANT9 = -1.100000;
+  static const ::std::string& STRING_CONSTANT_UTF8();
   enum : int32_t { A1 = 1 };
   enum : int32_t { A2 = 1 };
   enum : int32_t { A3 = 1 };
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ArrayOfInterfaces.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ArrayOfInterfaces.java
index a4f89ab..6628a8e 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ArrayOfInterfaces.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ArrayOfInterfaces.java
@@ -99,13 +99,9 @@
       @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
       {
         java.lang.String descriptor = DESCRIPTOR;
-        switch (code)
-        {
-          case INTERFACE_TRANSACTION:
-          {
-            reply.writeString(descriptor);
-            return true;
-          }
+        if (code == INTERFACE_TRANSACTION) {
+          reply.writeString(descriptor);
+          return true;
         }
         switch (code)
         {
@@ -206,13 +202,9 @@
         if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
           data.enforceInterface(descriptor);
         }
-        switch (code)
-        {
-          case INTERFACE_TRANSACTION:
-          {
-            reply.writeString(descriptor);
-            return true;
-          }
+        if (code == INTERFACE_TRANSACTION) {
+          reply.writeString(descriptor);
+          return true;
         }
         switch (code)
         {
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ICircular.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ICircular.java
index e24b2b4..0bd23dc 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ICircular.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ICircular.java
@@ -69,13 +69,9 @@
       if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
         data.enforceInterface(descriptor);
       }
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
+      if (code == INTERFACE_TRANSACTION) {
+        reply.writeString(descriptor);
+        return true;
       }
       switch (code)
       {
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IDeprecated.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IDeprecated.java
index d9c1d4b..723f90b 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IDeprecated.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IDeprecated.java
@@ -60,13 +60,9 @@
     @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
     {
       java.lang.String descriptor = DESCRIPTOR;
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
+      if (code == INTERFACE_TRANSACTION) {
+        reply.writeString(descriptor);
+        return true;
       }
       switch (code)
       {
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java
index 95c3526..e80b1b6 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java
@@ -69,13 +69,9 @@
       if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
         data.enforceInterface(descriptor);
       }
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
+      if (code == INTERFACE_TRANSACTION) {
+        reply.writeString(descriptor);
+        return true;
       }
       switch (code)
       {
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java
index 1fdf120..39f55af 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java
@@ -69,13 +69,9 @@
       if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
         data.enforceInterface(descriptor);
       }
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
+      if (code == INTERFACE_TRANSACTION) {
+        reply.writeString(descriptor);
+        return true;
       }
       switch (code)
       {
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java
index 325fd8f..e8e16ea 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java
@@ -69,13 +69,9 @@
       if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
         data.enforceInterface(descriptor);
       }
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
+      if (code == INTERFACE_TRANSACTION) {
+        reply.writeString(descriptor);
+        return true;
       }
       switch (code)
       {
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
index 650d907..6110111 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
@@ -931,13 +931,9 @@
       if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
         data.enforceInterface(descriptor);
       }
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
+      if (code == INTERFACE_TRANSACTION) {
+        reply.writeString(descriptor);
+        return true;
       }
       switch (code)
       {
@@ -3542,39 +3538,39 @@
   // extra line comment
   /* extra regular comment */
   /** const comment */
-  public static final int TEST_CONSTANT = 42;
-  public static final int TEST_CONSTANT2 = -42;
-  public static final int TEST_CONSTANT3 = 42;
-  public static final int TEST_CONSTANT4 = 4;
-  public static final int TEST_CONSTANT5 = -4;
-  public static final int TEST_CONSTANT6 = 0;
-  public static final int TEST_CONSTANT7 = 0;
-  public static final int TEST_CONSTANT8 = 0;
-  public static final int TEST_CONSTANT9 = 86;
-  public static final int TEST_CONSTANT10 = 165;
-  public static final int TEST_CONSTANT11 = 250;
-  public static final int TEST_CONSTANT12 = -1;
-  public static final byte BYTE_TEST_CONSTANT = 17;
-  public static final long LONG_TEST_CONSTANT = 1099511627776L;
-  public static final String STRING_TEST_CONSTANT = "foo";
-  public static final String STRING_TEST_CONSTANT2 = "bar";
-  public static final float FLOAT_TEST_CONSTANT = 1.000000f;
-  public static final float FLOAT_TEST_CONSTANT2 = -1.000000f;
-  public static final float FLOAT_TEST_CONSTANT3 = 1.000000f;
-  public static final float FLOAT_TEST_CONSTANT4 = 2.200000f;
-  public static final float FLOAT_TEST_CONSTANT5 = -2.200000f;
-  public static final float FLOAT_TEST_CONSTANT6 = -0.000000f;
-  public static final float FLOAT_TEST_CONSTANT7 = 0.000000f;
-  public static final double DOUBLE_TEST_CONSTANT = 1.000000;
-  public static final double DOUBLE_TEST_CONSTANT2 = -1.000000;
-  public static final double DOUBLE_TEST_CONSTANT3 = 1.000000;
-  public static final double DOUBLE_TEST_CONSTANT4 = 2.200000;
-  public static final double DOUBLE_TEST_CONSTANT5 = -2.200000;
-  public static final double DOUBLE_TEST_CONSTANT6 = -0.000000;
-  public static final double DOUBLE_TEST_CONSTANT7 = 0.000000;
-  public static final double DOUBLE_TEST_CONSTANT8 = 1.100000;
-  public static final double DOUBLE_TEST_CONSTANT9 = -1.100000;
-  public static final String STRING_TEST_CONSTANT_UTF8 = "baz";
+  public static final int CONSTANT = 42;
+  public static final int CONSTANT2 = -42;
+  public static final int CONSTANT3 = 42;
+  public static final int CONSTANT4 = 4;
+  public static final int CONSTANT5 = -4;
+  public static final int CONSTANT6 = 0;
+  public static final int CONSTANT7 = 0;
+  public static final int CONSTANT8 = 0;
+  public static final int CONSTANT9 = 86;
+  public static final int CONSTANT10 = 165;
+  public static final int CONSTANT11 = 250;
+  public static final int CONSTANT12 = -1;
+  public static final byte BYTE_CONSTANT = 17;
+  public static final long LONG_CONSTANT = 1099511627776L;
+  public static final String STRING_CONSTANT = "foo";
+  public static final String STRING_CONSTANT2 = "bar";
+  public static final float FLOAT_CONSTANT = 1.000000f;
+  public static final float FLOAT_CONSTANT2 = -1.000000f;
+  public static final float FLOAT_CONSTANT3 = 1.000000f;
+  public static final float FLOAT_CONSTANT4 = 2.200000f;
+  public static final float FLOAT_CONSTANT5 = -2.200000f;
+  public static final float FLOAT_CONSTANT6 = -0.000000f;
+  public static final float FLOAT_CONSTANT7 = 0.000000f;
+  public static final double DOUBLE_CONSTANT = 1.000000;
+  public static final double DOUBLE_CONSTANT2 = -1.000000;
+  public static final double DOUBLE_CONSTANT3 = 1.000000;
+  public static final double DOUBLE_CONSTANT4 = 2.200000;
+  public static final double DOUBLE_CONSTANT5 = -2.200000;
+  public static final double DOUBLE_CONSTANT6 = -0.000000;
+  public static final double DOUBLE_CONSTANT7 = 0.000000;
+  public static final double DOUBLE_CONSTANT8 = 1.100000;
+  public static final double DOUBLE_CONSTANT9 = -1.100000;
+  public static final String STRING_CONSTANT_UTF8 = "baz";
   // All these constant expressions should be equal to 1
   public static final int A1 = 1;
   public static final int A2 = 1;
@@ -3993,13 +3989,9 @@
         @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
         {
           java.lang.String descriptor = DESCRIPTOR;
-          switch (code)
-          {
-            case INTERFACE_TRANSACTION:
-            {
-              reply.writeString(descriptor);
-              return true;
-            }
+          if (code == INTERFACE_TRANSACTION) {
+            reply.writeString(descriptor);
+            return true;
           }
           switch (code)
           {
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ListOfInterfaces.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ListOfInterfaces.java
index cb240f4..0599124 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ListOfInterfaces.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ListOfInterfaces.java
@@ -99,13 +99,9 @@
       @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
       {
         java.lang.String descriptor = DESCRIPTOR;
-        switch (code)
-        {
-          case INTERFACE_TRANSACTION:
-          {
-            reply.writeString(descriptor);
-            return true;
-          }
+        if (code == INTERFACE_TRANSACTION) {
+          reply.writeString(descriptor);
+          return true;
         }
         switch (code)
         {
@@ -206,13 +202,9 @@
         if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
           data.enforceInterface(descriptor);
         }
-        switch (code)
-        {
-          case INTERFACE_TRANSACTION:
-          {
-            reply.writeString(descriptor);
-            return true;
-          }
+        if (code == INTERFACE_TRANSACTION) {
+          reply.writeString(descriptor);
+          return true;
         }
         switch (code)
         {
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/nested/INestedService.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/nested/INestedService.java
index 004f0e3..265146e 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/nested/INestedService.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/nested/INestedService.java
@@ -76,13 +76,9 @@
       if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
         data.enforceInterface(descriptor);
       }
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
+      if (code == INTERFACE_TRANSACTION) {
+        reply.writeString(descriptor);
+        return true;
       }
       switch (code)
       {
@@ -287,13 +283,9 @@
         if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
           data.enforceInterface(descriptor);
         }
-        switch (code)
-        {
-          case INTERFACE_TRANSACTION:
-          {
-            reply.writeString(descriptor);
-            return true;
-          }
+        if (code == INTERFACE_TRANSACTION) {
+          reply.writeString(descriptor);
+          return true;
         }
         switch (code)
         {
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp
index bc34377..42d6d07 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp
@@ -4222,9 +4222,9 @@
 ITestService::ITestService() {}
 ITestService::~ITestService() {}
 
-const char* ITestService::STRING_TEST_CONSTANT = "foo";
-const char* ITestService::STRING_TEST_CONSTANT2 = "bar";
-const char* ITestService::STRING_TEST_CONSTANT_UTF8 = "baz";
+const char* ITestService::STRING_CONSTANT = "foo";
+const char* ITestService::STRING_CONSTANT2 = "bar";
+const char* ITestService::STRING_CONSTANT_UTF8 = "baz";
 
 std::shared_ptr<ITestService> ITestService::fromBinder(const ::ndk::SpAIBinder& binder) {
   if (!AIBinder_associateClass(binder.get(), _g_aidl_android_aidl_tests_ITestService_clazz)) { return nullptr; }
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
index c23f776..2302110 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
@@ -345,39 +345,39 @@
       return os.str();
     }
   };
-  enum : int32_t { TEST_CONSTANT = 42 };
-  enum : int32_t { TEST_CONSTANT2 = -42 };
-  enum : int32_t { TEST_CONSTANT3 = 42 };
-  enum : int32_t { TEST_CONSTANT4 = 4 };
-  enum : int32_t { TEST_CONSTANT5 = -4 };
-  enum : int32_t { TEST_CONSTANT6 = 0 };
-  enum : int32_t { TEST_CONSTANT7 = 0 };
-  enum : int32_t { TEST_CONSTANT8 = 0 };
-  enum : int32_t { TEST_CONSTANT9 = 86 };
-  enum : int32_t { TEST_CONSTANT10 = 165 };
-  enum : int32_t { TEST_CONSTANT11 = 250 };
-  enum : int32_t { TEST_CONSTANT12 = -1 };
-  enum : int8_t { BYTE_TEST_CONSTANT = 17 };
-  enum : int64_t { LONG_TEST_CONSTANT = 1099511627776L };
-  static const char* STRING_TEST_CONSTANT;
-  static const char* STRING_TEST_CONSTANT2;
-  static constexpr float FLOAT_TEST_CONSTANT = 1.000000f;
-  static constexpr float FLOAT_TEST_CONSTANT2 = -1.000000f;
-  static constexpr float FLOAT_TEST_CONSTANT3 = 1.000000f;
-  static constexpr float FLOAT_TEST_CONSTANT4 = 2.200000f;
-  static constexpr float FLOAT_TEST_CONSTANT5 = -2.200000f;
-  static constexpr float FLOAT_TEST_CONSTANT6 = -0.000000f;
-  static constexpr float FLOAT_TEST_CONSTANT7 = 0.000000f;
-  static constexpr double DOUBLE_TEST_CONSTANT = 1.000000;
-  static constexpr double DOUBLE_TEST_CONSTANT2 = -1.000000;
-  static constexpr double DOUBLE_TEST_CONSTANT3 = 1.000000;
-  static constexpr double DOUBLE_TEST_CONSTANT4 = 2.200000;
-  static constexpr double DOUBLE_TEST_CONSTANT5 = -2.200000;
-  static constexpr double DOUBLE_TEST_CONSTANT6 = -0.000000;
-  static constexpr double DOUBLE_TEST_CONSTANT7 = 0.000000;
-  static constexpr double DOUBLE_TEST_CONSTANT8 = 1.100000;
-  static constexpr double DOUBLE_TEST_CONSTANT9 = -1.100000;
-  static const char* STRING_TEST_CONSTANT_UTF8;
+  enum : int32_t { CONSTANT = 42 };
+  enum : int32_t { CONSTANT2 = -42 };
+  enum : int32_t { CONSTANT3 = 42 };
+  enum : int32_t { CONSTANT4 = 4 };
+  enum : int32_t { CONSTANT5 = -4 };
+  enum : int32_t { CONSTANT6 = 0 };
+  enum : int32_t { CONSTANT7 = 0 };
+  enum : int32_t { CONSTANT8 = 0 };
+  enum : int32_t { CONSTANT9 = 86 };
+  enum : int32_t { CONSTANT10 = 165 };
+  enum : int32_t { CONSTANT11 = 250 };
+  enum : int32_t { CONSTANT12 = -1 };
+  enum : int8_t { BYTE_CONSTANT = 17 };
+  enum : int64_t { LONG_CONSTANT = 1099511627776L };
+  static const char* STRING_CONSTANT;
+  static const char* STRING_CONSTANT2;
+  static constexpr float FLOAT_CONSTANT = 1.000000f;
+  static constexpr float FLOAT_CONSTANT2 = -1.000000f;
+  static constexpr float FLOAT_CONSTANT3 = 1.000000f;
+  static constexpr float FLOAT_CONSTANT4 = 2.200000f;
+  static constexpr float FLOAT_CONSTANT5 = -2.200000f;
+  static constexpr float FLOAT_CONSTANT6 = -0.000000f;
+  static constexpr float FLOAT_CONSTANT7 = 0.000000f;
+  static constexpr double DOUBLE_CONSTANT = 1.000000;
+  static constexpr double DOUBLE_CONSTANT2 = -1.000000;
+  static constexpr double DOUBLE_CONSTANT3 = 1.000000;
+  static constexpr double DOUBLE_CONSTANT4 = 2.200000;
+  static constexpr double DOUBLE_CONSTANT5 = -2.200000;
+  static constexpr double DOUBLE_CONSTANT6 = -0.000000;
+  static constexpr double DOUBLE_CONSTANT7 = 0.000000;
+  static constexpr double DOUBLE_CONSTANT8 = 1.100000;
+  static constexpr double DOUBLE_CONSTANT9 = -1.100000;
+  static const char* STRING_CONSTANT_UTF8;
   enum : int32_t { A1 = 1 };
   enum : int32_t { A2 = 1 };
   enum : int32_t { A3 = 1 };
diff --git a/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/INoPermission.java b/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/INoPermission.java
index fc65b93..3d96568 100644
--- a/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/INoPermission.java
+++ b/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/INoPermission.java
@@ -68,13 +68,9 @@
       if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
         data.enforceInterface(descriptor);
       }
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
+      if (code == INTERFACE_TRANSACTION) {
+        reply.writeString(descriptor);
+        return true;
       }
       switch (code)
       {
diff --git a/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/IProtected.java b/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/IProtected.java
index 6c35028..87ddac0 100644
--- a/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/IProtected.java
+++ b/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/IProtected.java
@@ -20,7 +20,13 @@
     {
     }
     // Used by the integration tests to dynamically set permissions that are considered granted.
-    @Override public void SetGranted(java.util.List<java.lang.String> permissions) throws android.os.RemoteException
+    @Override public void Grant(java.lang.String permission) throws android.os.RemoteException
+    {
+    }
+    @Override public void Revoke(java.lang.String permission) throws android.os.RemoteException
+    {
+    }
+    @Override public void RevokeAll() throws android.os.RemoteException
     {
     }
     @Override
@@ -87,9 +93,17 @@
         {
           return "NonManifestPermission";
         }
-        case TRANSACTION_SetGranted:
+        case TRANSACTION_Grant:
         {
-          return "SetGranted";
+          return "Grant";
+        }
+        case TRANSACTION_Revoke:
+        {
+          return "Revoke";
+        }
+        case TRANSACTION_RevokeAll:
+        {
+          return "RevokeAll";
         }
         default:
         {
@@ -108,13 +122,9 @@
       if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
         data.enforceInterface(descriptor);
       }
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
+      if (code == INTERFACE_TRANSACTION) {
+        reply.writeString(descriptor);
+        return true;
       }
       switch (code)
       {
@@ -142,12 +152,27 @@
           reply.writeNoException();
           break;
         }
-        case TRANSACTION_SetGranted:
+        case TRANSACTION_Grant:
         {
-          java.util.List<java.lang.String> _arg0;
-          _arg0 = data.createStringArrayList();
+          java.lang.String _arg0;
+          _arg0 = data.readString();
           data.enforceNoDataAvail();
-          this.SetGranted(_arg0);
+          this.Grant(_arg0);
+          reply.writeNoException();
+          break;
+        }
+        case TRANSACTION_Revoke:
+        {
+          java.lang.String _arg0;
+          _arg0 = data.readString();
+          data.enforceNoDataAvail();
+          this.Revoke(_arg0);
+          reply.writeNoException();
+          break;
+        }
+        case TRANSACTION_RevokeAll:
+        {
+          this.RevokeAll();
           reply.writeNoException();
           break;
         }
@@ -230,14 +255,43 @@
         }
       }
       // Used by the integration tests to dynamically set permissions that are considered granted.
-      @Override public void SetGranted(java.util.List<java.lang.String> permissions) throws android.os.RemoteException
+      @Override public void Grant(java.lang.String permission) throws android.os.RemoteException
       {
         android.os.Parcel _data = android.os.Parcel.obtain(asBinder());
         android.os.Parcel _reply = android.os.Parcel.obtain();
         try {
           _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeStringList(permissions);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_SetGranted, _data, _reply, 0);
+          _data.writeString(permission);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_Grant, _data, _reply, 0);
+          _reply.readException();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+      }
+      @Override public void Revoke(java.lang.String permission) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain(asBinder());
+        android.os.Parcel _reply = android.os.Parcel.obtain();
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeString(permission);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_Revoke, _data, _reply, 0);
+          _reply.readException();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+      }
+      @Override public void RevokeAll() throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain(asBinder());
+        android.os.Parcel _reply = android.os.Parcel.obtain();
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RevokeAll, _data, _reply, 0);
           _reply.readException();
         }
         finally {
@@ -249,32 +303,32 @@
     static final int TRANSACTION_PermissionProtected = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
     /** Helper method to enforce permissions for PermissionProtected */
     protected void PermissionProtected_enforcePermission() throws SecurityException {
-      android.content.AttributionSource source = new android.content.AttributionSource(getCallingUid(), null, null);
-      mEnforcer.enforcePermission(android.Manifest.permission.READ_PHONE_STATE, source);
+      mEnforcer.enforcePermission(android.Manifest.permission.READ_PHONE_STATE, getCallingPid(), getCallingUid());
     }
     static final int TRANSACTION_MultiplePermissionsAll = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
+    static final String[] PERMISSIONS_MultiplePermissionsAll = {android.Manifest.permission.INTERNET, android.Manifest.permission.VIBRATE};
     /** Helper method to enforce permissions for MultiplePermissionsAll */
     protected void MultiplePermissionsAll_enforcePermission() throws SecurityException {
-      android.content.AttributionSource source = new android.content.AttributionSource(getCallingUid(), null, null);
-      mEnforcer.enforcePermissionAllOf(new String[]{android.Manifest.permission.INTERNET, android.Manifest.permission.VIBRATE}, source);
+      mEnforcer.enforcePermissionAllOf(PERMISSIONS_MultiplePermissionsAll, getCallingPid(), getCallingUid());
     }
     static final int TRANSACTION_MultiplePermissionsAny = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
+    static final String[] PERMISSIONS_MultiplePermissionsAny = {android.Manifest.permission.INTERNET, android.Manifest.permission.VIBRATE};
     /** Helper method to enforce permissions for MultiplePermissionsAny */
     protected void MultiplePermissionsAny_enforcePermission() throws SecurityException {
-      android.content.AttributionSource source = new android.content.AttributionSource(getCallingUid(), null, null);
-      mEnforcer.enforcePermissionAnyOf(new String[]{android.Manifest.permission.INTERNET, android.Manifest.permission.VIBRATE}, source);
+      mEnforcer.enforcePermissionAnyOf(PERMISSIONS_MultiplePermissionsAny, getCallingPid(), getCallingUid());
     }
     static final int TRANSACTION_NonManifestPermission = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
     /** Helper method to enforce permissions for NonManifestPermission */
     protected void NonManifestPermission_enforcePermission() throws SecurityException {
-      android.content.AttributionSource source = new android.content.AttributionSource(getCallingUid(), null, null);
-      mEnforcer.enforcePermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, source);
+      mEnforcer.enforcePermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, getCallingPid(), getCallingUid());
     }
-    static final int TRANSACTION_SetGranted = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
+    static final int TRANSACTION_Grant = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
+    static final int TRANSACTION_Revoke = (android.os.IBinder.FIRST_CALL_TRANSACTION + 5);
+    static final int TRANSACTION_RevokeAll = (android.os.IBinder.FIRST_CALL_TRANSACTION + 6);
     /** @hide */
     public int getMaxTransactionId()
     {
-      return 4;
+      return 6;
     }
   }
   public static final java.lang.String DESCRIPTOR = "android$aidl$tests$permission$IProtected".replace('$', '.');
@@ -288,5 +342,9 @@
   public void NonManifestPermission() throws android.os.RemoteException;
   // Used by the integration tests to dynamically set permissions that are considered granted.
   @android.annotation.RequiresNoPermission
-  public void SetGranted(java.util.List<java.lang.String> permissions) throws android.os.RemoteException;
+  public void Grant(java.lang.String permission) throws android.os.RemoteException;
+  @android.annotation.RequiresNoPermission
+  public void Revoke(java.lang.String permission) throws android.os.RemoteException;
+  @android.annotation.RequiresNoPermission
+  public void RevokeAll() throws android.os.RemoteException;
 }
diff --git a/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/IProtectedInterface.java b/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/IProtectedInterface.java
index 24f1f2d..ade2de8 100644
--- a/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/IProtectedInterface.java
+++ b/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/IProtectedInterface.java
@@ -86,13 +86,9 @@
       if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
         data.enforceInterface(descriptor);
       }
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
+      if (code == INTERFACE_TRANSACTION) {
+        reply.writeString(descriptor);
+        return true;
       }
       switch (code)
       {
@@ -162,14 +158,12 @@
     static final int TRANSACTION_Method1 = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
     /** Helper method to enforce permissions for Method1 */
     protected void Method1_enforcePermission() throws SecurityException {
-      android.content.AttributionSource source = new android.content.AttributionSource(getCallingUid(), null, null);
-      mEnforcer.enforcePermission(android.Manifest.permission.ACCESS_FINE_LOCATION, source);
+      mEnforcer.enforcePermission(android.Manifest.permission.ACCESS_FINE_LOCATION, getCallingPid(), getCallingUid());
     }
     static final int TRANSACTION_Method2 = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
     /** Helper method to enforce permissions for Method2 */
     protected void Method2_enforcePermission() throws SecurityException {
-      android.content.AttributionSource source = new android.content.AttributionSource(getCallingUid(), null, null);
-      mEnforcer.enforcePermission(android.Manifest.permission.ACCESS_FINE_LOCATION, source);
+      mEnforcer.enforcePermission(android.Manifest.permission.ACCESS_FINE_LOCATION, getCallingPid(), getCallingUid());
     }
     /** @hide */
     public int getMaxTransactionId()
diff --git a/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/platform/IProtected.java b/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/platform/IProtected.java
index d6fde91..c0e6cf7 100644
--- a/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/platform/IProtected.java
+++ b/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/platform/IProtected.java
@@ -79,13 +79,9 @@
       if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
         data.enforceInterface(descriptor);
       }
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
+      if (code == INTERFACE_TRANSACTION) {
+        reply.writeString(descriptor);
+        return true;
       }
       switch (code)
       {
@@ -137,9 +133,10 @@
       }
     }
     static final int TRANSACTION_ProtectedWithSourceAttribution = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
+    static final String[] PERMISSIONS_ProtectedWithSourceAttribution = {android.Manifest.permission.INTERNET, android.Manifest.permission.VIBRATE};
     /** Helper method to enforce permissions for ProtectedWithSourceAttribution */
-    protected void ProtectedWithSourceAttribution_enforcePermission(android.content.AttributionSource source) throws SecurityException {
-      mEnforcer.enforcePermissionAllOf(new String[]{android.Manifest.permission.INTERNET, android.Manifest.permission.VIBRATE}, source);
+    protected void ProtectedWithSourceAttribution_enforcePermission() throws SecurityException {
+      mEnforcer.enforcePermissionAllOf(PERMISSIONS_ProtectedWithSourceAttribution, getCallingPid(), getCallingUid());
     }
     /** @hide */
     public int getMaxTransactionId()
diff --git a/tests/golden_output/aidl-test-interface-platform-java-source/gen/android/aidl/tests/permission/platform/IProtected.java b/tests/golden_output/aidl-test-interface-platform-java-source/gen/android/aidl/tests/permission/platform/IProtected.java
deleted file mode 100644
index 7b6d96f..0000000
--- a/tests/golden_output/aidl-test-interface-platform-java-source/gen/android/aidl/tests/permission/platform/IProtected.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * This file is auto-generated.  DO NOT MODIFY.
- */
-package android.aidl.tests.permission.platform;
-public interface IProtected extends android.os.IInterface
-{
-  /** Default implementation for IProtected. */
-  public static class Default implements android.aidl.tests.permission.platform.IProtected
-  {
-    @Override public void ProtectedWithSourceAttribution(android.content.AttributionSource source) throws android.os.RemoteException
-    {
-    }
-    @Override
-    public android.os.IBinder asBinder() {
-      return null;
-    }
-  }
-  /** Local-side IPC implementation stub class. */
-  public static abstract class Stub extends android.os.Binder implements android.aidl.tests.permission.platform.IProtected
-  {
-    /** Construct the stub at attach it to the interface. */
-    public Stub()
-    {
-      this.attachInterface(this, DESCRIPTOR);
-    }
-    /**
-     * Cast an IBinder object into an android.aidl.tests.permission.platform.IProtected interface,
-     * generating a proxy if needed.
-     */
-    public static android.aidl.tests.permission.platform.IProtected asInterface(android.os.IBinder obj)
-    {
-      if ((obj==null)) {
-        return null;
-      }
-      android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
-      if (((iin!=null)&&(iin instanceof android.aidl.tests.permission.platform.IProtected))) {
-        return ((android.aidl.tests.permission.platform.IProtected)iin);
-      }
-      return new android.aidl.tests.permission.platform.IProtected.Stub.Proxy(obj);
-    }
-    @Override public android.os.IBinder asBinder()
-    {
-      return this;
-    }
-    @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
-    {
-      java.lang.String descriptor = DESCRIPTOR;
-      if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
-        data.enforceInterface(descriptor);
-      }
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
-      }
-      switch (code)
-      {
-        case TRANSACTION_ProtectedWithSourceAttribution:
-        {
-          android.content.AttributionSource _arg0;
-          _arg0 = data.readTypedObject(android.content.AttributionSource.CREATOR);
-          data.enforceNoDataAvail();
-          if (((this.permissionCheckerWrapper(android.Manifest.permission.INTERNET, this.getCallingPid(), _arg0)&&this.permissionCheckerWrapper(android.Manifest.permission.VIBRATE, this.getCallingPid(), _arg0))!=true)) {
-            throw new SecurityException("Access denied, requires: allOf = {android.Manifest.permission.INTERNET, android.Manifest.permission.VIBRATE}");
-          }
-          this.ProtectedWithSourceAttribution(_arg0);
-          reply.writeNoException();
-          break;
-        }
-        default:
-        {
-          return super.onTransact(code, data, reply, flags);
-        }
-      }
-      return true;
-    }
-    private static class Proxy implements android.aidl.tests.permission.platform.IProtected
-    {
-      private android.os.IBinder mRemote;
-      Proxy(android.os.IBinder remote)
-      {
-        mRemote = remote;
-      }
-      @Override public android.os.IBinder asBinder()
-      {
-        return mRemote;
-      }
-      public java.lang.String getInterfaceDescriptor()
-      {
-        return DESCRIPTOR;
-      }
-      @Override public void ProtectedWithSourceAttribution(android.content.AttributionSource source) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeTypedObject(source, 0);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_ProtectedWithSourceAttribution, _data, _reply, 0);
-          _reply.readException();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-      }
-    }
-    private boolean permissionCheckerWrapper(
-        String permission, int pid, android.content.AttributionSource attributionSource) {
-      android.content.Context ctx =
-          android.app.ActivityThread.currentActivityThread().getSystemContext();
-      return (android.content.PermissionChecker.checkPermissionForDataDelivery(
-              ctx, permission, pid, attributionSource, "" /*message*/) ==
-          android.content.PermissionChecker.PERMISSION_GRANTED);
-    }
-    static final int TRANSACTION_ProtectedWithSourceAttribution = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
-  }
-  public static final java.lang.String DESCRIPTOR = "android$aidl$tests$permission$platform$IProtected".replace('$', '.');
-  @android.annotation.EnforcePermission(allOf = {android.Manifest.permission.INTERNET, android.Manifest.permission.VIBRATE})
-  public void ProtectedWithSourceAttribution(android.content.AttributionSource source) throws android.os.RemoteException;
-}
diff --git a/tests/golden_output/aidl-test-interface-platform-java-source/gen/android/aidl/tests/permission/platform/IProtected.java.d b/tests/golden_output/aidl-test-interface-platform-java-source/gen/android/aidl/tests/permission/platform/IProtected.java.d
deleted file mode 100644
index 51e500e..0000000
--- a/tests/golden_output/aidl-test-interface-platform-java-source/gen/android/aidl/tests/permission/platform/IProtected.java.d
+++ /dev/null
@@ -1,3 +0,0 @@
-out/soong/.intermediates/system/tools/aidl/aidl-test-interface-platform-java-source/gen/android/aidl/tests/permission/platform/IProtected.java : \
-  system/tools/aidl/tests/android/aidl/tests/permission/platform/IProtected.aidl \
-  frameworks/base/core/java/android/content/AttributionSource.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ArrayOfInterfaces.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ArrayOfInterfaces.rs
index 93ad590..b51a45e 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ArrayOfInterfaces.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ArrayOfInterfaces.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#ArrayOfInterfaces {
 }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/BackendType.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/BackendType.rs
index 30160f7..b8094bd 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/BackendType.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/BackendType.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 use binder::declare_binder_enum;
 declare_binder_enum! {
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ByteEnum.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ByteEnum.rs
index f7926cb..74916a8 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ByteEnum.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ByteEnum.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 use binder::declare_binder_enum;
 declare_binder_enum! {
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/CircularParcelable.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/CircularParcelable.rs
index 89bcb37..51a152c 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/CircularParcelable.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/CircularParcelable.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#CircularParcelable {
   pub r#testService: Option<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_12_ITestService>>,
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ConstantExpressionEnum.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ConstantExpressionEnum.rs
index eac40f1..8dcf892 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ConstantExpressionEnum.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ConstantExpressionEnum.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 use binder::declare_binder_enum;
 declare_binder_enum! {
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedEnum.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedEnum.rs
index e3e4c23..19a61c1 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedEnum.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedEnum.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 use binder::declare_binder_enum;
 declare_binder_enum! {
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedParcelable.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedParcelable.rs
index 621f5f6..fe96103 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedParcelable.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedParcelable.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 #[deprecated = "test"]
 pub struct r#DeprecatedParcelable {
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/FixedSize.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/FixedSize.rs
index cd73b70..32ceebe 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/FixedSize.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/FixedSize.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#FixedSize {
 }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/GenericStructuredParcelable.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/GenericStructuredParcelable.rs
index 9323b15..7c102e0 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/GenericStructuredParcelable.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/GenericStructuredParcelable.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug, Clone, Copy, Eq, PartialEq)]
 pub struct r#GenericStructuredParcelable<T,U,B,> {
   pub r#a: i32,
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ICircular.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ICircular.rs
index b6b55bd..78cc854 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ICircular.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ICircular.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 #![allow(non_snake_case)]
 #[allow(unused_imports)] use binder::binder_impl::IBinderInternal;
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IDeprecated.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IDeprecated.rs
index 5e67e1b..a2376ea 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IDeprecated.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IDeprecated.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 #![allow(non_snake_case)]
 #[allow(unused_imports)] use binder::binder_impl::IBinderInternal;
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INamedCallback.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INamedCallback.rs
index 9ba10f0..adbf7c8 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INamedCallback.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INamedCallback.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 #![allow(non_snake_case)]
 #[allow(unused_imports)] use binder::binder_impl::IBinderInternal;
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INewName.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INewName.rs
index b0fdf91..899ec29 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INewName.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INewName.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 #![allow(non_snake_case)]
 #[allow(unused_imports)] use binder::binder_impl::IBinderInternal;
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IOldName.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IOldName.rs
index 97d330b..14963df 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IOldName.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IOldName.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 #![allow(non_snake_case)]
 #[allow(unused_imports)] use binder::binder_impl::IBinderInternal;
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
index b9b36d3..8cef263 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 #![allow(non_snake_case)]
 #[allow(unused_imports)] use binder::binder_impl::IBinderInternal;
@@ -745,39 +745,39 @@
 lazy_static! {
   static ref DEFAULT_IMPL: std::sync::Mutex<ITestServiceDefaultRef> = std::sync::Mutex::new(None);
 }
-pub const r#TEST_CONSTANT: i32 = 42;
-pub const r#TEST_CONSTANT2: i32 = -42;
-pub const r#TEST_CONSTANT3: i32 = 42;
-pub const r#TEST_CONSTANT4: i32 = 4;
-pub const r#TEST_CONSTANT5: i32 = -4;
-pub const r#TEST_CONSTANT6: i32 = 0;
-pub const r#TEST_CONSTANT7: i32 = 0;
-pub const r#TEST_CONSTANT8: i32 = 0;
-pub const r#TEST_CONSTANT9: i32 = 86;
-pub const r#TEST_CONSTANT10: i32 = 165;
-pub const r#TEST_CONSTANT11: i32 = 250;
-pub const r#TEST_CONSTANT12: i32 = -1;
-pub const r#BYTE_TEST_CONSTANT: i8 = 17;
-pub const r#LONG_TEST_CONSTANT: i64 = 1099511627776;
-pub const r#STRING_TEST_CONSTANT: &str = "foo";
-pub const r#STRING_TEST_CONSTANT2: &str = "bar";
-pub const r#FLOAT_TEST_CONSTANT: f32 = 1.000000f32;
-pub const r#FLOAT_TEST_CONSTANT2: f32 = -1.000000f32;
-pub const r#FLOAT_TEST_CONSTANT3: f32 = 1.000000f32;
-pub const r#FLOAT_TEST_CONSTANT4: f32 = 2.200000f32;
-pub const r#FLOAT_TEST_CONSTANT5: f32 = -2.200000f32;
-pub const r#FLOAT_TEST_CONSTANT6: f32 = -0.000000f32;
-pub const r#FLOAT_TEST_CONSTANT7: f32 = 0.000000f32;
-pub const r#DOUBLE_TEST_CONSTANT: f64 = 1.000000f64;
-pub const r#DOUBLE_TEST_CONSTANT2: f64 = -1.000000f64;
-pub const r#DOUBLE_TEST_CONSTANT3: f64 = 1.000000f64;
-pub const r#DOUBLE_TEST_CONSTANT4: f64 = 2.200000f64;
-pub const r#DOUBLE_TEST_CONSTANT5: f64 = -2.200000f64;
-pub const r#DOUBLE_TEST_CONSTANT6: f64 = -0.000000f64;
-pub const r#DOUBLE_TEST_CONSTANT7: f64 = 0.000000f64;
-pub const r#DOUBLE_TEST_CONSTANT8: f64 = 1.100000f64;
-pub const r#DOUBLE_TEST_CONSTANT9: f64 = -1.100000f64;
-pub const r#STRING_TEST_CONSTANT_UTF8: &str = "baz";
+pub const r#CONSTANT: i32 = 42;
+pub const r#CONSTANT2: i32 = -42;
+pub const r#CONSTANT3: i32 = 42;
+pub const r#CONSTANT4: i32 = 4;
+pub const r#CONSTANT5: i32 = -4;
+pub const r#CONSTANT6: i32 = 0;
+pub const r#CONSTANT7: i32 = 0;
+pub const r#CONSTANT8: i32 = 0;
+pub const r#CONSTANT9: i32 = 86;
+pub const r#CONSTANT10: i32 = 165;
+pub const r#CONSTANT11: i32 = 250;
+pub const r#CONSTANT12: i32 = -1;
+pub const r#BYTE_CONSTANT: i8 = 17;
+pub const r#LONG_CONSTANT: i64 = 1099511627776;
+pub const r#STRING_CONSTANT: &str = "foo";
+pub const r#STRING_CONSTANT2: &str = "bar";
+pub const r#FLOAT_CONSTANT: f32 = 1.000000f32;
+pub const r#FLOAT_CONSTANT2: f32 = -1.000000f32;
+pub const r#FLOAT_CONSTANT3: f32 = 1.000000f32;
+pub const r#FLOAT_CONSTANT4: f32 = 2.200000f32;
+pub const r#FLOAT_CONSTANT5: f32 = -2.200000f32;
+pub const r#FLOAT_CONSTANT6: f32 = -0.000000f32;
+pub const r#FLOAT_CONSTANT7: f32 = 0.000000f32;
+pub const r#DOUBLE_CONSTANT: f64 = 1.000000f64;
+pub const r#DOUBLE_CONSTANT2: f64 = -1.000000f64;
+pub const r#DOUBLE_CONSTANT3: f64 = 1.000000f64;
+pub const r#DOUBLE_CONSTANT4: f64 = 2.200000f64;
+pub const r#DOUBLE_CONSTANT5: f64 = -2.200000f64;
+pub const r#DOUBLE_CONSTANT6: f64 = -0.000000f64;
+pub const r#DOUBLE_CONSTANT7: f64 = 0.000000f64;
+pub const r#DOUBLE_CONSTANT8: f64 = 1.100000f64;
+pub const r#DOUBLE_CONSTANT9: f64 = -1.100000f64;
+pub const r#STRING_CONSTANT_UTF8: &str = "baz";
 pub const r#A1: i32 = 1;
 pub const r#A2: i32 = 1;
 pub const r#A3: i32 = 1;
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IntEnum.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IntEnum.rs
index a2bf3cc..1a177ac 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IntEnum.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IntEnum.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 use binder::declare_binder_enum;
 declare_binder_enum! {
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ListOfInterfaces.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ListOfInterfaces.rs
index 7f426ce..4d5df45 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ListOfInterfaces.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ListOfInterfaces.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#ListOfInterfaces {
 }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/LongEnum.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/LongEnum.rs
index 75084a4..761c884 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/LongEnum.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/LongEnum.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 use binder::declare_binder_enum;
 declare_binder_enum! {
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/OtherParcelableForToString.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/OtherParcelableForToString.rs
index 6b415e0..52cb607 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/OtherParcelableForToString.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/OtherParcelableForToString.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#OtherParcelableForToString {
   pub r#field: String,
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ParcelableForToString.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ParcelableForToString.rs
index 9dec2a4..c9d249f 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ParcelableForToString.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ParcelableForToString.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#ParcelableForToString {
   pub r#intValue: i32,
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/RecursiveList.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/RecursiveList.rs
index f439d5f..3a6d064 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/RecursiveList.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/RecursiveList.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#RecursiveList {
   pub r#value: i32,
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/StructuredParcelable.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/StructuredParcelable.rs
index 1c7c016..995acf9 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/StructuredParcelable.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/StructuredParcelable.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug, Clone, PartialEq)]
 pub struct r#StructuredParcelable {
   pub r#shouldContainThreeFs: Vec<i32>,
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs
index ab57464..1b83256 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug, Clone, PartialEq)]
 pub enum r#Union {
   Ns(Vec<i32>),
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs
index bce4d54..db5d756 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub enum r#UnionWithFd {
   Num(i32),
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/ExtendableParcelable.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/ExtendableParcelable.rs
index f99c361..fefe7d8 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/ExtendableParcelable.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/ExtendableParcelable.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#ExtendableParcelable {
   pub r#a: i32,
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/MyExt.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/MyExt.rs
index 8a5dd8e..c509151 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/MyExt.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/MyExt.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#MyExt {
   pub r#a: i32,
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/MyExt2.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/MyExt2.rs
index 7b3a737..e15316c 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/MyExt2.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/MyExt2.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#MyExt2 {
   pub r#a: i32,
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/MyExtLike.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/MyExtLike.rs
index 1abcc72..c7a7d61 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/MyExtLike.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/extension/MyExtLike.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#MyExtLike {
   pub r#a: i32,
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/nested/DeeplyNested.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/nested/DeeplyNested.rs
index adcd682..395f194 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/nested/DeeplyNested.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/nested/DeeplyNested.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#DeeplyNested {
 }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/nested/INestedService.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/nested/INestedService.rs
index aa747db..2acc79a 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/nested/INestedService.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/nested/INestedService.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 #![allow(non_snake_case)]
 #[allow(unused_imports)] use binder::binder_impl::IBinderInternal;
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/nested/ParcelableWithNested.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/nested/ParcelableWithNested.rs
index 4cff721..282f2c1 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/nested/ParcelableWithNested.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/nested/ParcelableWithNested.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#ParcelableWithNested {
   pub r#status: crate::mangled::_7_android_4_aidl_5_tests_6_nested_20_ParcelableWithNested_6_Status,
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs
index dbec338..731010d 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug, Clone, PartialEq)]
 pub enum r#EnumUnion {
   IntEnum(crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum),
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs
index cfc7372..c2b59ac 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug, Clone, PartialEq)]
 pub enum r#UnionInUnion {
   First(crate::mangled::_7_android_4_aidl_5_tests_6_unions_9_EnumUnion),
diff --git a/tests/golden_output/aidl-test-versioned-interface-V1-java-source/gen/android/aidl/versioned/tests/IFooInterface.java b/tests/golden_output/aidl-test-versioned-interface-V1-java-source/gen/android/aidl/versioned/tests/IFooInterface.java
index 7d66241..6dca016 100644
--- a/tests/golden_output/aidl-test-versioned-interface-V1-java-source/gen/android/aidl/versioned/tests/IFooInterface.java
+++ b/tests/golden_output/aidl-test-versioned-interface-V1-java-source/gen/android/aidl/versioned/tests/IFooInterface.java
@@ -76,25 +76,19 @@
       if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
         data.enforceInterface(descriptor);
       }
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
-        case TRANSACTION_getInterfaceVersion:
-        {
-          reply.writeNoException();
-          reply.writeInt(getInterfaceVersion());
-          return true;
-        }
-        case TRANSACTION_getInterfaceHash:
-        {
-          reply.writeNoException();
-          reply.writeString(getInterfaceHash());
-          return true;
-        }
+      if (code == INTERFACE_TRANSACTION) {
+        reply.writeString(descriptor);
+        return true;
+      }
+      else if (code == TRANSACTION_getInterfaceVersion) {
+        reply.writeNoException();
+        reply.writeInt(getInterfaceVersion());
+        return true;
+      }
+      else if (code == TRANSACTION_getInterfaceHash) {
+        reply.writeNoException();
+        reply.writeString(getInterfaceHash());
+        return true;
       }
       switch (code)
       {
diff --git a/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/BazUnion.rs b/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/BazUnion.rs
index 267922b..eda30af 100644
--- a/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/BazUnion.rs
+++ b/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/BazUnion.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub enum r#BazUnion {
   IntNum(i32),
diff --git a/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/Foo.rs b/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/Foo.rs
index 4c5e493..67443d2 100644
--- a/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/Foo.rs
+++ b/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/Foo.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #[derive(Debug)]
 pub struct r#Foo {
 }
diff --git a/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/IFooInterface.rs b/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/IFooInterface.rs
index 1395a77..a5b1d01 100644
--- a/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/IFooInterface.rs
+++ b/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/IFooInterface.rs
@@ -1,5 +1,5 @@
 #![forbid(unsafe_code)]
-#![rustfmt::skip]
+#![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(non_upper_case_globals)]
 #![allow(non_snake_case)]
 #[allow(unused_imports)] use binder::binder_impl::IBinderInternal;
diff --git a/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/ILoggableInterface.java b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/ILoggableInterface.java
index c8ab851..c061734 100644
--- a/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/ILoggableInterface.java
+++ b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/ILoggableInterface.java
@@ -69,13 +69,9 @@
       if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
         data.enforceInterface(descriptor);
       }
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
+      if (code == INTERFACE_TRANSACTION) {
+        reply.writeString(descriptor);
+        return true;
       }
       switch (code)
       {
@@ -289,13 +285,9 @@
         if (code >= android.os.IBinder.FIRST_CALL_TRANSACTION && code <= android.os.IBinder.LAST_CALL_TRANSACTION) {
           data.enforceInterface(descriptor);
         }
-        switch (code)
-        {
-          case INTERFACE_TRANSACTION:
-          {
-            reply.writeString(descriptor);
-            return true;
-          }
+        if (code == INTERFACE_TRANSACTION) {
+          reply.writeString(descriptor);
+          return true;
         }
         switch (code)
         {
diff --git a/tests/java/src/android/aidl/permission/service/FakePermissionEnforcer.java b/tests/java/src/android/aidl/permission/service/FakePermissionEnforcer.java
deleted file mode 100644
index 92ec830..0000000
--- a/tests/java/src/android/aidl/permission/service/FakePermissionEnforcer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.aidl.permission.service;
-
-import static android.permission.PermissionManager.PERMISSION_GRANTED;
-import static android.permission.PermissionManager.PERMISSION_HARD_DENIED;
-
-import android.annotation.NonNull;
-import android.content.AttributionSource;
-import java.util.List;
-
-/* Fake for android.os.PermissionEnforcer
- */
-public class FakePermissionEnforcer extends android.os.PermissionEnforcer {
-  private List<String> mGranted;
-
-  public void setGranted(List<String> granted) { mGranted = granted; }
-
-  @Override
-  protected int checkPermission(@NonNull String permission, @NonNull AttributionSource source) {
-    if (mGranted != null && mGranted.contains(permission)) {
-      return PERMISSION_GRANTED;
-    }
-    return PERMISSION_HARD_DENIED;
-  }
-}
diff --git a/tests/java/src/android/aidl/permission/service/PermissionTestService.java b/tests/java/src/android/aidl/permission/service/PermissionTestService.java
index b65b5df..f3bb0ce 100644
--- a/tests/java/src/android/aidl/permission/service/PermissionTestService.java
+++ b/tests/java/src/android/aidl/permission/service/PermissionTestService.java
@@ -20,6 +20,7 @@
 import android.annotation.EnforcePermission;
 import android.os.Binder;
 import android.os.ServiceManager;
+import android.os.test.FakePermissionEnforcer;
 import java.util.List;
 
 public class PermissionTestService extends IProtected.Stub {
@@ -62,7 +63,17 @@
   }
 
   @Override
-  public void SetGranted(List<String> permissions) {
-    mPermissionEnforcer.setGranted(permissions);
+  public void Grant(String permission) {
+    mPermissionEnforcer.grant(permission);
+  }
+
+  @Override
+  public void Revoke(String permission) {
+    mPermissionEnforcer.revoke(permission);
+  }
+
+  @Override
+  public void RevokeAll() {
+    mPermissionEnforcer.revokeAll();
   }
 }
diff --git a/tests/java/src/android/aidl/permission/tests/PermissionTests.java b/tests/java/src/android/aidl/permission/tests/PermissionTests.java
index 91a9f42..6eb9035 100644
--- a/tests/java/src/android/aidl/permission/tests/PermissionTests.java
+++ b/tests/java/src/android/aidl/permission/tests/PermissionTests.java
@@ -39,42 +39,48 @@
   @Test
   public void testProtected() throws Exception {
     // Requires READ_PHONE_STATE.
-    service.SetGranted(List.of());
     assertThrows(SecurityException.class, () -> service.PermissionProtected());
-    service.SetGranted(List.of("android.permission.READ_PHONE_STATE"));
+    service.Grant("android.permission.READ_PHONE_STATE");
     service.PermissionProtected();
   }
 
   @Test
   public void testMultiplePermissionsAll() throws Exception {
     // Requires INTERNET and VIBRATE.
-    service.SetGranted(List.of());
     assertThrows(SecurityException.class, () -> service.MultiplePermissionsAll());
-    service.SetGranted(List.of("android.permission.INTERNET"));
+
+    service.Grant("android.permission.INTERNET");
     assertThrows(SecurityException.class, () -> service.MultiplePermissionsAll());
-    service.SetGranted(List.of("android.permission.VIBRATE"));
+    service.RevokeAll();
+
+    service.Grant("android.permission.VIBRATE");
     assertThrows(SecurityException.class, () -> service.MultiplePermissionsAll());
-    service.SetGranted(List.of("android.permission.INTERNET", "android.permission.VIBRATE"));
+    service.RevokeAll();
+
+    service.Grant("android.permission.INTERNET");
+    service.Grant("android.permission.VIBRATE");
     service.MultiplePermissionsAll();
   }
 
   @Test
   public void testMultiplePermissionsAny() throws Exception {
     // Requires INTERNET or VIBRATE.
-    service.SetGranted(List.of());
     assertThrows(SecurityException.class, () -> service.MultiplePermissionsAny());
-    service.SetGranted(List.of("android.permission.INTERNET"));
+
+    service.Grant("android.permission.INTERNET");
     service.MultiplePermissionsAny();
-    service.SetGranted(List.of("android.permission.VIBRATE"));
+    service.RevokeAll();
+
+    service.Grant("android.permission.VIBRATE");
     service.MultiplePermissionsAny();
   }
 
   @Test
   public void testNonManifestPermission() throws Exception {
     // Requires android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK
-    service.SetGranted(List.of());
     assertThrows(SecurityException.class, () -> service.NonManifestPermission());
-    service.SetGranted(List.of("android.permission.MAINLINE_NETWORK_STACK"));
+
+    service.Grant("android.permission.MAINLINE_NETWORK_STACK");
     service.NonManifestPermission();
   }
 
diff --git a/tests/java/src/android/aidl/permission/tests/PermissionTestsLocal.java b/tests/java/src/android/aidl/permission/tests/PermissionTestsLocal.java
index 3e3146e..22aa6bd 100644
--- a/tests/java/src/android/aidl/permission/tests/PermissionTestsLocal.java
+++ b/tests/java/src/android/aidl/permission/tests/PermissionTestsLocal.java
@@ -20,10 +20,10 @@
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThrows;
 
-import android.aidl.permission.service.FakePermissionEnforcer;
 import android.aidl.permission.service.PermissionTestService;
 import android.aidl.tests.permission.IProtected;
 import android.os.RemoteException;
+import android.os.test.FakePermissionEnforcer;
 import org.junit.Before;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
@@ -34,5 +34,6 @@
   public void setUp() throws RemoteException {
     service = new PermissionTestService(new FakePermissionEnforcer());
     assertNotNull(service);
+    service.RevokeAll();
   }
 }
diff --git a/tests/java/src/android/aidl/permission/tests/PermissionTestsRemote.java b/tests/java/src/android/aidl/permission/tests/PermissionTestsRemote.java
index 5602fe8..0d8620e 100644
--- a/tests/java/src/android/aidl/permission/tests/PermissionTestsRemote.java
+++ b/tests/java/src/android/aidl/permission/tests/PermissionTestsRemote.java
@@ -35,5 +35,6 @@
     assertNotNull(binder);
     service = IProtected.Stub.asInterface(binder);
     assertNotNull(service);
+    service.RevokeAll();
   }
 }
diff --git a/tests/java/src/android/aidl/tests/TestServiceClient.java b/tests/java/src/android/aidl/tests/TestServiceClient.java
index 6f29886..8ce2a19 100644
--- a/tests/java/src/android/aidl/tests/TestServiceClient.java
+++ b/tests/java/src/android/aidl/tests/TestServiceClient.java
@@ -120,14 +120,9 @@
 
     @Test
     public void testConstRepeat() throws RemoteException {
-        int query[] = {ITestService.TEST_CONSTANT,
-                       ITestService.TEST_CONSTANT2,
-                       ITestService.TEST_CONSTANT3,
-                       ITestService.TEST_CONSTANT4,
-                       ITestService.TEST_CONSTANT5,
-                       ITestService.TEST_CONSTANT6,
-                       ITestService.TEST_CONSTANT7,
-                       ITestService.TEST_CONSTANT8};
+        int query[] = {ITestService.CONSTANT, ITestService.CONSTANT2, ITestService.CONSTANT3,
+            ITestService.CONSTANT4, ITestService.CONSTANT5, ITestService.CONSTANT6,
+            ITestService.CONSTANT7, ITestService.CONSTANT8};
         for (int i = 0; i < query.length; i++) {
             assertThat(service.RepeatInt(query[i]), is(query[i]));
         }
@@ -135,10 +130,10 @@
 
     @Test
     public void testConstFloatRepeat() throws RemoteException {
-        float query[] = {ITestService.FLOAT_TEST_CONSTANT, ITestService.FLOAT_TEST_CONSTANT2,
-            ITestService.FLOAT_TEST_CONSTANT3, ITestService.FLOAT_TEST_CONSTANT4,
-            ITestService.FLOAT_TEST_CONSTANT5, ITestService.FLOAT_TEST_CONSTANT6,
-            ITestService.FLOAT_TEST_CONSTANT7};
+        float query[] = {ITestService.FLOAT_CONSTANT, ITestService.FLOAT_CONSTANT2,
+            ITestService.FLOAT_CONSTANT3, ITestService.FLOAT_CONSTANT4,
+            ITestService.FLOAT_CONSTANT5, ITestService.FLOAT_CONSTANT6,
+            ITestService.FLOAT_CONSTANT7};
         for (int i = 0; i < query.length; i++) {
             assertThat(service.RepeatFloat(query[i]), is(query[i]));
         }
@@ -146,10 +141,10 @@
 
     @Test
     public void testConstDoubleRepeat() throws RemoteException {
-        double query[] = {ITestService.DOUBLE_TEST_CONSTANT, ITestService.DOUBLE_TEST_CONSTANT2,
-            ITestService.DOUBLE_TEST_CONSTANT3, ITestService.DOUBLE_TEST_CONSTANT4,
-            ITestService.DOUBLE_TEST_CONSTANT5, ITestService.DOUBLE_TEST_CONSTANT6,
-            ITestService.DOUBLE_TEST_CONSTANT7};
+        double query[] = {ITestService.DOUBLE_CONSTANT, ITestService.DOUBLE_CONSTANT2,
+            ITestService.DOUBLE_CONSTANT3, ITestService.DOUBLE_CONSTANT4,
+            ITestService.DOUBLE_CONSTANT5, ITestService.DOUBLE_CONSTANT6,
+            ITestService.DOUBLE_CONSTANT7};
         for (int i = 0; i < query.length; i++) {
             assertThat(service.RepeatDouble(query[i]), is(query[i]));
         }
@@ -194,9 +189,7 @@
     @Test
     public void testStringListRepeat() throws RemoteException {
         List<String> queries = Arrays.asList(
-                "not empty", "", "\0",
-                ITestService.STRING_TEST_CONSTANT,
-                ITestService.STRING_TEST_CONSTANT2);
+            "not empty", "", "\0", ITestService.STRING_CONSTANT, ITestService.STRING_CONSTANT2);
         for (String query : queries) {
             assertThat(service.RepeatString(query), is(query));
         }
diff --git a/tests/lazy_test/Android.bp b/tests/lazy_test/Android.bp
index 9eb814c..dd44ae9 100644
--- a/tests/lazy_test/Android.bp
+++ b/tests/lazy_test/Android.bp
@@ -36,6 +36,7 @@
     system_ext_specific: true,
 
     shared_libs: [
+        "libbase",
         "libbinder",
         "liblog",
         "libutils",
diff --git a/tests/lazy_test/ServerCb.cpp b/tests/lazy_test/ServerCb.cpp
index bed9ec0..c05b889 100644
--- a/tests/lazy_test/ServerCb.cpp
+++ b/tests/lazy_test/ServerCb.cpp
@@ -29,6 +29,7 @@
 using android::binder::LazyServiceRegistrar;
 using android::binder::LazyTestServiceCb;
 
+// TODO: shouldn't be expanded or copied - instead, merge with server.cpp
 int main() {
   sp<LazyTestServiceCb> service = new LazyTestServiceCb();
 
diff --git a/tests/lazy_test/aidl_lazy_test_server.rc b/tests/lazy_test/aidl_lazy_test_server.rc
index 05c25b4..130173c 100644
--- a/tests/lazy_test/aidl_lazy_test_server.rc
+++ b/tests/lazy_test/aidl_lazy_test_server.rc
@@ -5,3 +5,10 @@
     group system
     oneshot
     disabled
+
+service aidl_lazy_test_quit /system_ext/bin/aidl_lazy_test_server quit
+    interface aidl aidl_lazy_test_quit
+    user system
+    group system
+    oneshot
+    disabled
diff --git a/tests/lazy_test/main.cpp b/tests/lazy_test/main.cpp
index 222d809..0556b73 100644
--- a/tests/lazy_test/main.cpp
+++ b/tests/lazy_test/main.cpp
@@ -33,9 +33,11 @@
 #include <utils/String8.h>
 
 using ::ILazyTestService;
+using ::android::DEAD_OBJECT;
 using ::android::IBinder;
 using ::android::IPCThreadState;
 using ::android::IServiceManager;
+using ::android::OK;
 using ::android::sp;
 using ::android::String16;
 using ::android::base::unique_fd;
@@ -61,6 +63,26 @@
   return manager->checkService(name) != nullptr;
 }
 
+TEST(AidlLazyQuitTest, Quits) {
+  const String16 quitter = String16("aidl_lazy_test_quit");
+  usleep(SHUTDOWN_WAIT_MS * 1000);
+  ASSERT_FALSE(isServiceRunning(quitter));
+
+  auto binder = waitForService(quitter);
+
+  // binder dies. Could also linkToDeath to switch to cond var.
+  for (size_t i = 0; i < 1000; i++) {
+    if (binder->pingBinder() != OK) break;
+    usleep(10000);
+  }
+  EXPECT_EQ(DEAD_OBJECT, binder->pingBinder());
+
+  // service should quit immediately, but wait a bit before checking
+  // so that servicemanager has time to process the death notification
+  usleep(SHUTDOWN_WAIT_MS * 1000 / 2);
+  ASSERT_FALSE(isServiceRunning(quitter));
+}
+
 class AidlLazyTest : public ::testing::Test {
  protected:
   sp<IServiceManager> manager;
diff --git a/tests/lazy_test/server.cpp b/tests/lazy_test/server.cpp
index 155cc88..a425dbf 100644
--- a/tests/lazy_test/server.cpp
+++ b/tests/lazy_test/server.cpp
@@ -1,8 +1,24 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android-base/logging.h>
 #include <binder/IBinder.h>
 #include <binder/IPCThreadState.h>
 #include <binder/IServiceManager.h>
 #include <binder/LazyServiceRegistrar.h>
-#include <utils/Log.h>
 #include "LazyTestService.h"
 
 using android::BBinder;
@@ -13,15 +29,46 @@
 using android::binder::LazyServiceRegistrar;
 using android::binder::LazyTestService;
 
-int main() {
-  sp<LazyTestService> service1 = new LazyTestService();
-  sp<LazyTestService> service2 = new LazyTestService();
+void setupDoubleLazyServer() {
+  sp<LazyTestService> service1 = sp<LazyTestService>::make();
+  sp<LazyTestService> service2 = sp<LazyTestService>::make();
+
+  // Simulate another callback here, to test to make sure the actual instance
+  // we are relying on doesn't have its state messed up when multiple client
+  // callbacks are registered.
+  // DO NOT COPY - INTENTIONALLY TESTING BAD BEHAVIOR
+  auto extra = LazyServiceRegistrar::createExtraTestInstance();
+  extra.forcePersist(true);  // don't allow this instance to handle process lifetime
+  CHECK_EQ(OK, extra.registerService(service1, "aidl_lazy_test_1"));
+  // DO NOT COPY - INTENTIONALLY TESTING BAD BEHAVIOR
 
   auto lazyRegistrar = LazyServiceRegistrar::getInstance();
-  LOG_ALWAYS_FATAL_IF(OK != lazyRegistrar.registerService(service1, "aidl_lazy_test_1"), "");
-  LOG_ALWAYS_FATAL_IF(OK != lazyRegistrar.registerService(service2, "aidl_lazy_test_2"), "");
+  CHECK_EQ(OK, lazyRegistrar.registerService(service1, "aidl_lazy_test_1"));
+  CHECK_EQ(OK, lazyRegistrar.registerService(service2, "aidl_lazy_test_2"));
+}
+
+void setupQuitterServer() {
+  auto lazyRegistrar = LazyServiceRegistrar::getInstance();
+  lazyRegistrar.setActiveServicesCallback([](bool hasClients) mutable -> bool {
+    // intentional bad behavior, for instance, simulating a system
+    // shutdown at this time
+    if (hasClients) exit(EXIT_SUCCESS);
+    return false;
+  });
+
+  sp<LazyTestService> service = sp<LazyTestService>::make();
+  CHECK_EQ(OK, lazyRegistrar.registerService(service, "aidl_lazy_test_quit"));
+}
+
+int main(int argc, char** argv) {
+  if (argc == 1) {
+    setupDoubleLazyServer();
+  } else if (argc == 2 && argv[1] == std::string("quit")) {
+    setupQuitterServer();
+  } else {
+    LOG_ALWAYS_FATAL("usage: %s [quit]", argv[0]);
+  }
 
   IPCThreadState::self()->joinThreadPool();
-
   return 1;
 }
diff --git a/tests/rust/test_client.rs b/tests/rust/test_client.rs
index cd24eae..8602754 100644
--- a/tests/rust/test_client.rs
+++ b/tests/rust/test_client.rs
@@ -121,10 +121,10 @@
     assert_eq!(ITestService::A55, 1);
     assert_eq!(ITestService::A56, 1);
     assert_eq!(ITestService::A57, 1);
-    assert_eq!(ITestService::FLOAT_TEST_CONSTANT4, 2.2_f32);
-    assert_eq!(ITestService::FLOAT_TEST_CONSTANT5, -2.2_f32);
-    assert_eq!(ITestService::DOUBLE_TEST_CONSTANT4, 2.2_f64);
-    assert_eq!(ITestService::DOUBLE_TEST_CONSTANT5, -2.2_f64);
+    assert_eq!(ITestService::FLOAT_CONSTANT4, 2.2_f32);
+    assert_eq!(ITestService::FLOAT_CONSTANT5, -2.2_f32);
+    assert_eq!(ITestService::DOUBLE_CONSTANT4, 2.2_f64);
+    assert_eq!(ITestService::DOUBLE_CONSTANT5, -2.2_f64);
 }
 
 #[test]
@@ -152,37 +152,37 @@
 test_primitive! {test_primitive_long, RepeatLong, 1i64 << 60}
 test_primitive! {test_primitive_float, RepeatFloat, 1.0f32 / 3.0f32}
 test_primitive! {test_primitive_double, RepeatDouble, 1.0f64 / 3.0f64}
-test_primitive! {test_primitive_byte_constant, RepeatByte, ITestService::BYTE_TEST_CONSTANT}
-test_primitive! {test_primitive_constant1, RepeatInt, ITestService::TEST_CONSTANT}
-test_primitive! {test_primitive_constant2, RepeatInt, ITestService::TEST_CONSTANT2}
-test_primitive! {test_primitive_constant3, RepeatInt, ITestService::TEST_CONSTANT3}
-test_primitive! {test_primitive_constant4, RepeatInt, ITestService::TEST_CONSTANT4}
-test_primitive! {test_primitive_constant5, RepeatInt, ITestService::TEST_CONSTANT5}
-test_primitive! {test_primitive_constant6, RepeatInt, ITestService::TEST_CONSTANT6}
-test_primitive! {test_primitive_constant7, RepeatInt, ITestService::TEST_CONSTANT7}
-test_primitive! {test_primitive_constant8, RepeatInt, ITestService::TEST_CONSTANT8}
-test_primitive! {test_primitive_constant9, RepeatInt, ITestService::TEST_CONSTANT9}
-test_primitive! {test_primitive_constant10, RepeatInt, ITestService::TEST_CONSTANT10}
-test_primitive! {test_primitive_constant11, RepeatInt, ITestService::TEST_CONSTANT11}
-test_primitive! {test_primitive_constant12, RepeatInt, ITestService::TEST_CONSTANT12}
-test_primitive! {test_primitive_long_constant, RepeatLong, ITestService::LONG_TEST_CONSTANT}
+test_primitive! {test_primitive_byte_constant, RepeatByte, ITestService::BYTE_CONSTANT}
+test_primitive! {test_primitive_constant1, RepeatInt, ITestService::CONSTANT}
+test_primitive! {test_primitive_constant2, RepeatInt, ITestService::CONSTANT2}
+test_primitive! {test_primitive_constant3, RepeatInt, ITestService::CONSTANT3}
+test_primitive! {test_primitive_constant4, RepeatInt, ITestService::CONSTANT4}
+test_primitive! {test_primitive_constant5, RepeatInt, ITestService::CONSTANT5}
+test_primitive! {test_primitive_constant6, RepeatInt, ITestService::CONSTANT6}
+test_primitive! {test_primitive_constant7, RepeatInt, ITestService::CONSTANT7}
+test_primitive! {test_primitive_constant8, RepeatInt, ITestService::CONSTANT8}
+test_primitive! {test_primitive_constant9, RepeatInt, ITestService::CONSTANT9}
+test_primitive! {test_primitive_constant10, RepeatInt, ITestService::CONSTANT10}
+test_primitive! {test_primitive_constant11, RepeatInt, ITestService::CONSTANT11}
+test_primitive! {test_primitive_constant12, RepeatInt, ITestService::CONSTANT12}
+test_primitive! {test_primitive_long_constant, RepeatLong, ITestService::LONG_CONSTANT}
 test_primitive! {test_primitive_byte_enum, RepeatByteEnum, ByteEnum::FOO}
 test_primitive! {test_primitive_int_enum, RepeatIntEnum, IntEnum::BAR}
 test_primitive! {test_primitive_long_enum, RepeatLongEnum, LongEnum::FOO}
-test_primitive! {test_primitive_float_constant, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT}
-test_primitive! {test_primitive_float_constant2, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT2}
-test_primitive! {test_primitive_float_constant3, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT3}
-test_primitive! {test_primitive_float_constant4, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT4}
-test_primitive! {test_primitive_float_constant5, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT5}
-test_primitive! {test_primitive_float_constant6, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT6}
-test_primitive! {test_primitive_float_constant7, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT7}
-test_primitive! {test_primitive_double_constant, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT}
-test_primitive! {test_primitive_double_constant2, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT2}
-test_primitive! {test_primitive_double_constant3, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT3}
-test_primitive! {test_primitive_double_constant4, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT4}
-test_primitive! {test_primitive_double_constant5, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT5}
-test_primitive! {test_primitive_double_constant6, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT6}
-test_primitive! {test_primitive_double_constant7, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT7}
+test_primitive! {test_primitive_float_constant, RepeatFloat, ITestService::FLOAT_CONSTANT}
+test_primitive! {test_primitive_float_constant2, RepeatFloat, ITestService::FLOAT_CONSTANT2}
+test_primitive! {test_primitive_float_constant3, RepeatFloat, ITestService::FLOAT_CONSTANT3}
+test_primitive! {test_primitive_float_constant4, RepeatFloat, ITestService::FLOAT_CONSTANT4}
+test_primitive! {test_primitive_float_constant5, RepeatFloat, ITestService::FLOAT_CONSTANT5}
+test_primitive! {test_primitive_float_constant6, RepeatFloat, ITestService::FLOAT_CONSTANT6}
+test_primitive! {test_primitive_float_constant7, RepeatFloat, ITestService::FLOAT_CONSTANT7}
+test_primitive! {test_primitive_double_constant, RepeatDouble, ITestService::DOUBLE_CONSTANT}
+test_primitive! {test_primitive_double_constant2, RepeatDouble, ITestService::DOUBLE_CONSTANT2}
+test_primitive! {test_primitive_double_constant3, RepeatDouble, ITestService::DOUBLE_CONSTANT3}
+test_primitive! {test_primitive_double_constant4, RepeatDouble, ITestService::DOUBLE_CONSTANT4}
+test_primitive! {test_primitive_double_constant5, RepeatDouble, ITestService::DOUBLE_CONSTANT5}
+test_primitive! {test_primitive_double_constant6, RepeatDouble, ITestService::DOUBLE_CONSTANT6}
+test_primitive! {test_primitive_double_constant7, RepeatDouble, ITestService::DOUBLE_CONSTANT7}
 
 #[test]
 fn test_repeat_string() {
@@ -195,8 +195,8 @@
         //   U+10437: The 'small letter yee' character in the deseret alphabet
         //   U+20AC: A euro sign
         String::from_utf16(&[0xD801, 0xDC37, 0x20AC]).expect("error converting string"),
-        ITestService::STRING_TEST_CONSTANT.into(),
-        ITestService::STRING_TEST_CONSTANT2.into(),
+        ITestService::STRING_CONSTANT.into(),
+        ITestService::STRING_CONSTANT2.into(),
     ];
     for input in &inputs {
         let result = service.RepeatString(input);
@@ -547,7 +547,7 @@
         "\0\0",
         std::str::from_utf8(&[0xF0, 0x90, 0x90, 0xB7, 0xE2, 0x82, 0xAC])
             .expect("error converting string"),
-        ITestService::STRING_TEST_CONSTANT_UTF8,
+        ITestService::STRING_CONSTANT_UTF8,
     ];
     for input in &inputs {
         let result = service.RepeatUtf8CppString(input);
@@ -569,7 +569,7 @@
                 .expect("error converting string")
                 .into(),
         ),
-        Some(ITestService::STRING_TEST_CONSTANT_UTF8.into()),
+        Some(ITestService::STRING_CONSTANT_UTF8.into()),
     ];
 
     // Java can't return a null list as a parameter
diff --git a/tests/trunk_stable_test/Android.bp b/tests/trunk_stable_test/Android.bp
new file mode 100644
index 0000000..64336e7
--- /dev/null
+++ b/tests/trunk_stable_test/Android.bp
@@ -0,0 +1,80 @@
+// Copyright (C) 2023 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "system_tools_aidl_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["system_tools_aidl_license"],
+}
+
+aidl_interface {
+    name: "android.aidl.test.trunk",
+    srcs: ["android/aidl/test/trunk/*.aidl"],
+    flags: ["-Werror"],
+    backend: {
+        rust: {
+            enabled: true,
+        },
+    },
+    versions_with_info: [
+        {
+            version: "1",
+            imports: [],
+        },
+    ],
+    frozen: false,
+
+}
+
+// Test using the same client and server source code including different
+// versions of the generated AIDL library.
+// This is an example of a possible solution to dealing with different
+// configurations of the build without needing to modify the source code.
+// This is the version of the test that uses the V1 library with the
+// V2 code behind #ifdefs.
+cc_test {
+    name: "aidl_ndk_V1_trunk_stable_unittest",
+    srcs: ["trunk_ndk_unittest.cpp"],
+    shared_libs: [
+        "libbinder_ndk",
+        "libbase",
+    ],
+    cflags: [
+        "-DAIDL_TEST_TRUNK_VER=1",
+    ],
+    static_libs: [
+        "android.aidl.test.trunk-V1-ndk",
+    ],
+    require_root: true,
+}
+
+// This is the version of the test that uses the latest V2 library.
+cc_test {
+    name: "aidl_ndk_V2_trunk_stable_unittest",
+    srcs: ["trunk_ndk_unittest.cpp"],
+    shared_libs: [
+        "libbinder_ndk",
+        "libbase",
+    ],
+    cflags: [
+        "-DAIDL_TEST_TRUNK_VER=2",
+    ],
+    static_libs: [
+        "android.aidl.test.trunk-V2-ndk",
+    ],
+    require_root: true,
+}
diff --git a/tests/trunk_stable_test/aidl_api/android.aidl.test.trunk/1/.hash b/tests/trunk_stable_test/aidl_api/android.aidl.test.trunk/1/.hash
new file mode 100644
index 0000000..890f5f5
--- /dev/null
+++ b/tests/trunk_stable_test/aidl_api/android.aidl.test.trunk/1/.hash
@@ -0,0 +1 @@
+88311b9118fb6fe9eff4a2ca19121de0587f6d5f
diff --git a/tests/trunk_stable_test/aidl_api/android.aidl.test.trunk/1/android/aidl/test/trunk/ITrunkStableTest.aidl b/tests/trunk_stable_test/aidl_api/android.aidl.test.trunk/1/android/aidl/test/trunk/ITrunkStableTest.aidl
new file mode 100644
index 0000000..98bbd2f
--- /dev/null
+++ b/tests/trunk_stable_test/aidl_api/android.aidl.test.trunk/1/android/aidl/test/trunk/ITrunkStableTest.aidl
@@ -0,0 +1,43 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.aidl.test.trunk;
+interface ITrunkStableTest {
+  android.aidl.test.trunk.ITrunkStableTest.MyParcelable repeatParcelable(in android.aidl.test.trunk.ITrunkStableTest.MyParcelable input);
+  android.aidl.test.trunk.ITrunkStableTest.MyEnum repeatEnum(in android.aidl.test.trunk.ITrunkStableTest.MyEnum input);
+  android.aidl.test.trunk.ITrunkStableTest.MyUnion repeatUnion(in android.aidl.test.trunk.ITrunkStableTest.MyUnion input);
+  void callMyCallback(in android.aidl.test.trunk.ITrunkStableTest.IMyCallback cb);
+  parcelable MyParcelable {
+    int a;
+    int b;
+  }
+  enum MyEnum {
+    ZERO,
+    ONE,
+    TWO,
+  }
+  union MyUnion {
+    int a;
+    int b;
+  }
+  interface IMyCallback {
+    android.aidl.test.trunk.ITrunkStableTest.MyParcelable repeatParcelable(in android.aidl.test.trunk.ITrunkStableTest.MyParcelable input);
+    android.aidl.test.trunk.ITrunkStableTest.MyEnum repeatEnum(in android.aidl.test.trunk.ITrunkStableTest.MyEnum input);
+    android.aidl.test.trunk.ITrunkStableTest.MyUnion repeatUnion(in android.aidl.test.trunk.ITrunkStableTest.MyUnion input);
+  }
+}
diff --git a/tests/trunk_stable_test/aidl_api/android.aidl.test.trunk/current/android/aidl/test/trunk/ITrunkStableTest.aidl b/tests/trunk_stable_test/aidl_api/android.aidl.test.trunk/current/android/aidl/test/trunk/ITrunkStableTest.aidl
new file mode 100644
index 0000000..2aa3bb1
--- /dev/null
+++ b/tests/trunk_stable_test/aidl_api/android.aidl.test.trunk/current/android/aidl/test/trunk/ITrunkStableTest.aidl
@@ -0,0 +1,52 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.aidl.test.trunk;
+interface ITrunkStableTest {
+  android.aidl.test.trunk.ITrunkStableTest.MyParcelable repeatParcelable(in android.aidl.test.trunk.ITrunkStableTest.MyParcelable input);
+  android.aidl.test.trunk.ITrunkStableTest.MyEnum repeatEnum(in android.aidl.test.trunk.ITrunkStableTest.MyEnum input);
+  android.aidl.test.trunk.ITrunkStableTest.MyUnion repeatUnion(in android.aidl.test.trunk.ITrunkStableTest.MyUnion input);
+  void callMyCallback(in android.aidl.test.trunk.ITrunkStableTest.IMyCallback cb);
+  android.aidl.test.trunk.ITrunkStableTest.MyOtherParcelable repeatOtherParcelable(in android.aidl.test.trunk.ITrunkStableTest.MyOtherParcelable input);
+  parcelable MyParcelable {
+    int a;
+    int b;
+    int c;
+  }
+  enum MyEnum {
+    ZERO,
+    ONE,
+    TWO,
+    THREE,
+  }
+  union MyUnion {
+    int a;
+    int b;
+    int c;
+  }
+  interface IMyCallback {
+    android.aidl.test.trunk.ITrunkStableTest.MyParcelable repeatParcelable(in android.aidl.test.trunk.ITrunkStableTest.MyParcelable input);
+    android.aidl.test.trunk.ITrunkStableTest.MyEnum repeatEnum(in android.aidl.test.trunk.ITrunkStableTest.MyEnum input);
+    android.aidl.test.trunk.ITrunkStableTest.MyUnion repeatUnion(in android.aidl.test.trunk.ITrunkStableTest.MyUnion input);
+    android.aidl.test.trunk.ITrunkStableTest.MyOtherParcelable repeatOtherParcelable(in android.aidl.test.trunk.ITrunkStableTest.MyOtherParcelable input);
+  }
+  parcelable MyOtherParcelable {
+    int a;
+    int b;
+  }
+}
diff --git a/tests/trunk_stable_test/android/aidl/test/trunk/ITrunkStableTest.aidl b/tests/trunk_stable_test/android/aidl/test/trunk/ITrunkStableTest.aidl
new file mode 100644
index 0000000..7c4ce2b
--- /dev/null
+++ b/tests/trunk_stable_test/android/aidl/test/trunk/ITrunkStableTest.aidl
@@ -0,0 +1,41 @@
+package android.aidl.test.trunk;
+
+interface ITrunkStableTest {
+    parcelable MyParcelable {
+        int a;
+        int b;
+        // New in V2
+        int c;
+    }
+    enum MyEnum {
+        ZERO,
+        ONE,
+        TWO,
+        // New in V2
+        THREE,
+    }
+    union MyUnion {
+        int a;
+        int b;
+        // New in V3
+        int c;
+    }
+    interface IMyCallback {
+        MyParcelable repeatParcelable(in MyParcelable input);
+        MyEnum repeatEnum(in MyEnum input);
+        MyUnion repeatUnion(in MyUnion input);
+        MyOtherParcelable repeatOtherParcelable(in MyOtherParcelable input);
+    }
+
+    MyParcelable repeatParcelable(in MyParcelable input);
+    MyEnum repeatEnum(in MyEnum input);
+    MyUnion repeatUnion(in MyUnion input);
+    void callMyCallback(in IMyCallback cb);
+
+    // New in V2
+    parcelable MyOtherParcelable {
+        int a;
+        int b;
+    }
+    MyOtherParcelable repeatOtherParcelable(in MyOtherParcelable input);
+}
diff --git a/tests/trunk_stable_test/trunk_ndk_unittest.cpp b/tests/trunk_stable_test/trunk_ndk_unittest.cpp
new file mode 100644
index 0000000..2ac721d
--- /dev/null
+++ b/tests/trunk_stable_test/trunk_ndk_unittest.cpp
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2023, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "gtest/gtest.h"
+
+/* Shared Client/Service includes */
+#include <aidl/android/aidl/test/trunk/BnTrunkStableTest.h>
+#include <aidl/android/aidl/test/trunk/ITrunkStableTest.h>
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <sys/prctl.h>
+
+/* AIDL Client includes */
+
+/* AIDL Service includes */
+#include <android/binder_process.h>
+
+#ifndef AIDL_TEST_TRUNK_VER
+#define AIDL_TEST_TRUNK_VER 2
+#endif
+
+using ::aidl::android::aidl::test::trunk::ITrunkStableTest;
+using ndk::ScopedAStatus;
+
+/* AIDL Client definition */
+class MyCallback : public ITrunkStableTest::BnMyCallback {
+ public:
+  ScopedAStatus repeatParcelable(const ITrunkStableTest::MyParcelable& in_input,
+                                 ITrunkStableTest::MyParcelable* _aidl_return) override {
+    *_aidl_return = in_input;
+    repeatParcelableCalled = true;
+    return ScopedAStatus::ok();
+  }
+  ScopedAStatus repeatEnum(const ITrunkStableTest::MyEnum in_input,
+                           ITrunkStableTest::MyEnum* _aidl_return) override {
+    *_aidl_return = in_input;
+    repeatEnumCalled = true;
+    return ScopedAStatus::ok();
+  }
+  ScopedAStatus repeatUnion(const ITrunkStableTest::MyUnion& in_input,
+                            ITrunkStableTest::MyUnion* _aidl_return) override {
+    *_aidl_return = in_input;
+    repeatUnionCalled = true;
+    return ScopedAStatus::ok();
+  }
+
+#if AIDL_TEST_TRUNK_VER >= 2
+  ScopedAStatus repeatOtherParcelable(const ITrunkStableTest::MyOtherParcelable& in_input,
+                                      ITrunkStableTest::MyOtherParcelable* _aidl_return) override {
+    *_aidl_return = in_input;
+    repeatOtherParcelableCalled = true;
+    return ScopedAStatus::ok();
+  }
+
+  bool repeatOtherParcelableCalled = false;
+#endif
+
+  bool repeatParcelableCalled = false;
+  bool repeatEnumCalled = false;
+  bool repeatUnionCalled = false;
+};
+
+class ClientTest : public testing::Test {
+ public:
+  void SetUp() override {
+    mService = ITrunkStableTest::fromBinder(
+        ndk::SpAIBinder(AServiceManager_waitForService(ITrunkStableTest::descriptor)));
+    ASSERT_NE(nullptr, mService);
+  }
+
+  std::shared_ptr<ITrunkStableTest> mService;
+};
+
+TEST_F(ClientTest, SanityCheck) {
+  ITrunkStableTest::MyParcelable a, b;
+  a.a = 12;
+  a.b = 13;
+#if AIDL_TEST_TRUNK_VER >= 2
+  a.c = 14;
+#endif
+  auto status = mService->repeatParcelable(a, &b);
+  EXPECT_TRUE(status.isOk());
+  EXPECT_EQ(a, b);
+}
+
+TEST_F(ClientTest, Callback) {
+  auto cb = ndk::SharedRefBase::make<MyCallback>();
+  auto status = mService->callMyCallback(cb);
+  EXPECT_TRUE(status.isOk());
+  EXPECT_TRUE(cb->repeatParcelableCalled);
+  EXPECT_TRUE(cb->repeatEnumCalled);
+  EXPECT_TRUE(cb->repeatUnionCalled);
+#if AIDL_TEST_TRUNK_VER >= 2
+  EXPECT_TRUE(cb->repeatOtherParcelableCalled);
+#endif
+}
+
+#if AIDL_TEST_TRUNK_VER >= 2
+TEST_F(ClientTest, CallV2Method) {
+  ITrunkStableTest::MyOtherParcelable a, b;
+  a.a = 12;
+  a.b = 13;
+  auto status = mService->repeatOtherParcelable(a, &b);
+  EXPECT_TRUE(status.isOk());
+  EXPECT_EQ(a, b);
+}
+#endif
+
+/* AIDL service definition */
+using ::aidl::android::aidl::test::trunk::BnTrunkStableTest;
+class TrunkStableTest : public BnTrunkStableTest {
+  ScopedAStatus repeatParcelable(const MyParcelable& in_input,
+                                 MyParcelable* _aidl_return) override {
+    *_aidl_return = in_input;
+    return ScopedAStatus::ok();
+  }
+  ScopedAStatus repeatEnum(const MyEnum in_input, MyEnum* _aidl_return) override {
+    *_aidl_return = in_input;
+    return ScopedAStatus::ok();
+  }
+  ScopedAStatus repeatUnion(const MyUnion& in_input, MyUnion* _aidl_return) override {
+    *_aidl_return = in_input;
+    return ScopedAStatus::ok();
+  }
+  ScopedAStatus callMyCallback(const std::shared_ptr<IMyCallback>& in_cb) override {
+    MyParcelable a, b;
+    MyEnum c = MyEnum::ZERO, d = MyEnum::ZERO;
+    MyUnion e, f;
+    auto status = in_cb->repeatParcelable(a, &b);
+    if (!status.isOk()) {
+      return status;
+    }
+    status = in_cb->repeatEnum(c, &d);
+    if (!status.isOk()) {
+      return status;
+    }
+    status = in_cb->repeatUnion(e, &f);
+#if AIDL_TEST_TRUNK_VER >= 2
+    if (!status.isOk()) {
+      return status;
+    }
+    MyOtherParcelable g, h;
+    status = in_cb->repeatOtherParcelable(g, &h);
+#endif
+    return status;
+  }
+#if AIDL_TEST_TRUNK_VER >= 2
+  ScopedAStatus repeatOtherParcelable(const ITrunkStableTest::MyOtherParcelable& in_input,
+                                      ITrunkStableTest::MyOtherParcelable* _aidl_return) override {
+    *_aidl_return = in_input;
+    return ScopedAStatus::ok();
+  }
+#endif
+};
+
+int run_service() {
+  auto trunk = ndk::SharedRefBase::make<TrunkStableTest>();
+  binder_status_t status =
+      AServiceManager_addService(trunk->asBinder().get(), TrunkStableTest::descriptor);
+  CHECK_EQ(status, STATUS_OK);
+
+  ABinderProcess_joinThreadPool();
+  return EXIT_FAILURE;  // should not reach
+}
+
+int main(int argc, char* argv[]) {
+  if (fork() == 0) {
+    prctl(PR_SET_PDEATHSIG, SIGHUP);
+    run_service();
+  }
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}