Merge tag 'android-security-11.0.0_r49' into int/11/fp3
Android security 11.0.0 release 49
* tag 'android-security-11.0.0_r49':
hidl_test_java: reflect new overread check in art
Change-Id: I915e0280f2d211e99165fcbc83b418142a35a935
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 16467e1..c758679 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -17,6 +17,10 @@
},
{
"name": "hidl_lazy_test"
+ },
+ {
+ "name": "hidl_metadata_test",
+ "host": true
}
]
}
diff --git a/build/hidl_interface.go b/build/hidl_interface.go
index c4a84a6..af6a293 100644
--- a/build/hidl_interface.go
+++ b/build/hidl_interface.go
@@ -89,6 +89,8 @@
Command: "rm -rf ${out} && " +
// Start the output array with an opening bracket.
"echo '[' >> ${out} && " +
+ // Add prebuilt declarations
+ "echo \"${extras}\" >> ${out} && " +
// Append each input file and a comma to the output.
"for file in $$(cat ${out}.rsp); do " +
"cat $$file >> ${out}; echo ',' >> ${out}; " +
@@ -96,10 +98,11 @@
// Remove the last comma, replacing it with the closing bracket.
"sed -i '$$d' ${out} && echo ']' >> ${out}",
Description: "Joining JSON objects into array ${out}",
- }, "files")
+ }, "extras", "files")
)
func init() {
+ android.RegisterModuleType("prebuilt_hidl_interfaces", prebuiltHidlInterfaceFactory)
android.RegisterModuleType("hidl_interface", hidlInterfaceFactory)
android.RegisterSingletonType("all_hidl_lints", allHidlLintsFactory)
android.RegisterMakeVarsProvider(pctx, makeVarsProvider)
@@ -128,6 +131,7 @@
}
var inheritanceHierarchyOutputs android.Paths
+ additionalInterfaces := []string{}
ctx.VisitDirectDeps(func(m android.Module) {
if !m.ExportedToMake() {
return
@@ -136,6 +140,8 @@
if t.properties.Language == "inheritance-hierarchy" {
inheritanceHierarchyOutputs = append(inheritanceHierarchyOutputs, t.genOutputs.Paths()...)
}
+ } else if t, ok := m.(*prebuiltHidlInterface); ok {
+ additionalInterfaces = append(additionalInterfaces, t.properties.Interfaces...)
}
})
@@ -146,7 +152,8 @@
Inputs: inheritanceHierarchyOutputs,
Output: m.inheritanceHierarchyPath,
Args: map[string]string{
- "files": strings.Join(inheritanceHierarchyOutputs.Strings(), " "),
+ "extras": strings.Join(wrap("{\\\"interface\\\":\\\"", additionalInterfaces, "\\\"},"), " "),
+ "files": strings.Join(inheritanceHierarchyOutputs.Strings(), " "),
},
})
}
@@ -439,6 +446,33 @@
return g
}
+type prebuiltHidlInterfaceProperties struct {
+ // List of interfaces to consider valid, e.g. "vendor.foo.bar@1.0::IFoo" for typo checking
+ // between init.rc, VINTF, and elsewhere. Note that inheritance properties will not be
+ // checked for these (but would be checked in a branch where the actual hidl_interface
+ // exists).
+ Interfaces []string
+}
+
+type prebuiltHidlInterface struct {
+ android.ModuleBase
+
+ properties prebuiltHidlInterfaceProperties
+}
+
+func (p *prebuiltHidlInterface) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
+
+func (p *prebuiltHidlInterface) DepsMutator(ctx android.BottomUpMutatorContext) {
+ ctx.AddReverseDependency(ctx.Module(), nil, hidlMetadataSingletonName)
+}
+
+func prebuiltHidlInterfaceFactory() android.Module {
+ i := &prebuiltHidlInterface{}
+ i.AddProperties(&i.properties)
+ android.InitAndroidModule(i)
+ return i
+}
+
type hidlInterfaceProperties struct {
// Vndk properties for interface library only.
cc.VndkProperties
diff --git a/metadata/Android.bp b/metadata/Android.bp
index 32b829a..044167f 100644
--- a/metadata/Android.bp
+++ b/metadata/Android.bp
@@ -15,6 +15,31 @@
export_include_dirs: ["include"],
}
+cc_test_host {
+ name: "hidl_metadata_test",
+ srcs: ["test.cpp"],
+ static_libs: [
+ "libhidlmetadata",
+ "libgmock",
+ ],
+ test_suites: ["general-tests"],
+}
+
+prebuilt_hidl_interfaces {
+ name: "hidl_metadata_test_interfaces1",
+ interfaces: [
+ "hidl.metadata.test@1.0::IBar",
+ ],
+}
+
+prebuilt_hidl_interfaces {
+ name: "hidl_metadata_test_interfaces2",
+ interfaces: [
+ "hidl.metadata.test@1.0::IBaz",
+ "hidl.metadata.test@1.0::IFoo",
+ ],
+}
+
// private impl below
cc_binary {
diff --git a/metadata/test.cpp b/metadata/test.cpp
new file mode 100644
index 0000000..fbd4bb5
--- /dev/null
+++ b/metadata/test.cpp
@@ -0,0 +1,45 @@
+/*
+ * 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 <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <hidl/metadata.h>
+
+#include <optional>
+
+using ::android::HidlInterfaceMetadata;
+using ::testing::ElementsAre;
+
+static std::optional<HidlInterfaceMetadata> metadataForModule(const std::string& name) {
+ for (const HidlInterfaceMetadata& info : HidlInterfaceMetadata::all()) {
+ if (name == info.name) return info;
+ }
+ return std::nullopt;
+}
+
+TEST(AidlMetadata, HasTestInstances) {
+ const auto& info = metadataForModule("android.hardware.tests.bar@1.0::IBar");
+ ASSERT_NE(info, std::nullopt);
+ EXPECT_THAT(info->inherited, ElementsAre("android.hardware.tests.foo@1.0::IFoo"));
+}
+
+TEST(AidlMetadata, HasPrebuiltInstances) {
+ for (const std::string& iface : {"hidl.metadata.test@1.0::IBar", "hidl.metadata.test@1.0::IBaz",
+ "hidl.metadata.test@1.0::IFoo"}) {
+ const auto& info = metadataForModule(iface);
+ ASSERT_NE(info, std::nullopt) << iface;
+ }
+}