• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2017 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package hidl
16
17import (
18	"fmt"
19	"sort"
20	"strings"
21	"sync"
22
23	"github.com/google/blueprint"
24	"github.com/google/blueprint/proptools"
25
26	"android/soong/android"
27	"android/soong/cc"
28	"android/soong/genrule"
29	"android/soong/java"
30)
31
32var (
33	hidlInterfaceSuffix       = "_interface"
34	hidlMetadataSingletonName = "hidl_metadata_json"
35
36	pctx = android.NewPackageContext("android/hidl")
37
38	hidl             = pctx.HostBinToolVariable("hidl", "hidl-gen")
39	vtsc             = pctx.HostBinToolVariable("vtsc", "vtsc")
40	hidlLint         = pctx.HostBinToolVariable("lint", "hidl-lint")
41	soong_zip        = pctx.HostBinToolVariable("soong_zip", "soong_zip")
42	intermediatesDir = pctx.IntermediatesPathVariable("intermediatesDir", "")
43
44	hidlRule = pctx.StaticRule("hidlRule", blueprint.RuleParams{
45		Depfile:     "${depfile}",
46		Deps:        blueprint.DepsGCC,
47		Command:     "rm -rf ${genDir} && ${hidl} -R -p . -d ${depfile} -o ${genDir} -L ${language} ${options} ${fqName}",
48		CommandDeps: []string{"${hidl}"},
49		Description: "HIDL ${language}: ${in} => ${out}",
50	}, "depfile", "fqName", "genDir", "language", "options")
51
52	hidlSrcJarRule = pctx.StaticRule("hidlSrcJarRule", blueprint.RuleParams{
53		Depfile: "${depfile}",
54		Deps:    blueprint.DepsGCC,
55		Command: "rm -rf ${genDir} && " +
56			"${hidl} -R -p . -d ${depfile} -o ${genDir}/srcs -L ${language} ${options} ${fqName} && " +
57			"${soong_zip} -o ${genDir}/srcs.srcjar -C ${genDir}/srcs -D ${genDir}/srcs",
58		CommandDeps: []string{"${hidl}", "${soong_zip}"},
59		Description: "HIDL ${language}: ${in} => srcs.srcjar",
60	}, "depfile", "fqName", "genDir", "language", "options")
61
62	vtsRule = pctx.StaticRule("vtsRule", blueprint.RuleParams{
63		Command:     "rm -rf ${genDir} && ${vtsc} -m${mode} -t${type} ${inputDir}/${packagePath} ${genDir}/${packagePath}",
64		CommandDeps: []string{"${vtsc}"},
65		Description: "VTS ${mode} ${type}: ${in} => ${out}",
66	}, "mode", "type", "inputDir", "genDir", "packagePath")
67
68	lintRule = pctx.StaticRule("lintRule", blueprint.RuleParams{
69		Command:     "rm -f ${output} && touch ${output} && ${lint} -j -e -R -p . ${options} ${fqName} > ${output}",
70		CommandDeps: []string{"${lint}"},
71		Description: "hidl-lint ${fqName}: ${out}",
72	}, "output", "options", "fqName")
73
74	zipLintRule = pctx.StaticRule("zipLintRule", blueprint.RuleParams{
75		Command:     "rm -f ${output} && ${soong_zip} -o ${output} -C ${intermediatesDir} ${files}",
76		CommandDeps: []string{"${soong_zip}"},
77		Description: "Zipping hidl-lints into ${output}",
78	}, "output", "files")
79
80	inheritanceHierarchyRule = pctx.StaticRule("inheritanceHierarchyRule", blueprint.RuleParams{
81		Command:     "rm -f ${out} && ${hidl} -L inheritance-hierarchy ${options} ${fqInterface} > ${out}",
82		CommandDeps: []string{"${hidl}"},
83		Description: "HIDL inheritance hierarchy: ${fqInterface} => ${out}",
84	}, "options", "fqInterface")
85
86	joinJsonObjectsToArrayRule = pctx.StaticRule("joinJsonObjectsToArrayRule", blueprint.RuleParams{
87		Rspfile:        "$out.rsp",
88		RspfileContent: "$files",
89		Command: "rm -rf ${out} && " +
90			// Start the output array with an opening bracket.
91			"echo '[' >> ${out} && " +
92			// Add prebuilt declarations
93			"echo \"${extras}\" >> ${out} && " +
94			// Append each input file and a comma to the output.
95			"for file in $$(cat ${out}.rsp); do " +
96			"cat $$file >> ${out}; echo ',' >> ${out}; " +
97			"done && " +
98			// Remove the last comma, replacing it with the closing bracket.
99			"sed -i '$$d' ${out} && echo ']' >> ${out}",
100		Description: "Joining JSON objects into array ${out}",
101	}, "extras", "files")
102)
103
104func init() {
105	android.RegisterModuleType("prebuilt_hidl_interfaces", prebuiltHidlInterfaceFactory)
106	android.RegisterModuleType("hidl_interface", hidlInterfaceFactory)
107	android.RegisterSingletonType("all_hidl_lints", allHidlLintsFactory)
108	android.RegisterMakeVarsProvider(pctx, makeVarsProvider)
109	android.RegisterModuleType("hidl_interfaces_metadata", hidlInterfacesMetadataSingletonFactory)
110	pctx.Import("android/soong/android")
111}
112
113func hidlInterfacesMetadataSingletonFactory() android.Module {
114	i := &hidlInterfacesMetadataSingleton{}
115	android.InitAndroidModule(i)
116	return i
117}
118
119type hidlInterfacesMetadataSingleton struct {
120	android.ModuleBase
121
122	inheritanceHierarchyPath android.OutputPath
123}
124
125var _ android.OutputFileProducer = (*hidlInterfacesMetadataSingleton)(nil)
126
127func (m *hidlInterfacesMetadataSingleton) GenerateAndroidBuildActions(ctx android.ModuleContext) {
128	if m.Name() != hidlMetadataSingletonName {
129		ctx.PropertyErrorf("name", "must be %s", hidlMetadataSingletonName)
130		return
131	}
132
133	var inheritanceHierarchyOutputs android.Paths
134	additionalInterfaces := []string{}
135	ctx.VisitDirectDeps(func(m android.Module) {
136		if !m.ExportedToMake() {
137			return
138		}
139		if t, ok := m.(*hidlGenRule); ok {
140			if t.properties.Language == "inheritance-hierarchy" {
141				inheritanceHierarchyOutputs = append(inheritanceHierarchyOutputs, t.genOutputs.Paths()...)
142			}
143		} else if t, ok := m.(*prebuiltHidlInterface); ok {
144			additionalInterfaces = append(additionalInterfaces, t.properties.Interfaces...)
145		}
146	})
147
148	m.inheritanceHierarchyPath = android.PathForIntermediates(ctx, "hidl_inheritance_hierarchy.json")
149
150	ctx.Build(pctx, android.BuildParams{
151		Rule:   joinJsonObjectsToArrayRule,
152		Inputs: inheritanceHierarchyOutputs,
153		Output: m.inheritanceHierarchyPath,
154		Args: map[string]string{
155			"extras": strings.Join(wrap("{\\\"interface\\\":\\\"", additionalInterfaces, "\\\"},"), " "),
156			"files":  strings.Join(inheritanceHierarchyOutputs.Strings(), " "),
157		},
158	})
159}
160
161func (m *hidlInterfacesMetadataSingleton) OutputFiles(tag string) (android.Paths, error) {
162	if tag != "" {
163		return nil, fmt.Errorf("unsupported tag %q", tag)
164	}
165
166	return android.Paths{m.inheritanceHierarchyPath}, nil
167}
168
169func allHidlLintsFactory() android.Singleton {
170	return &allHidlLintsSingleton{}
171}
172
173type allHidlLintsSingleton struct {
174	outPath string
175}
176
177func (m *allHidlLintsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
178	var hidlLintOutputs android.Paths
179	ctx.VisitAllModules(func(m android.Module) {
180		if t, ok := m.(*hidlGenRule); ok {
181			if t.properties.Language == "lint" {
182				if len(t.genOutputs) == 1 {
183					hidlLintOutputs = append(hidlLintOutputs, t.genOutputs[0])
184				} else {
185					panic("-hidl-lint target was not configured correctly")
186				}
187			}
188		}
189	})
190
191	outPath := android.PathForIntermediates(ctx, "hidl-lint.zip")
192	m.outPath = outPath.String()
193
194	ctx.Build(pctx, android.BuildParams{
195		Rule:   zipLintRule,
196		Inputs: hidlLintOutputs,
197		Output: outPath,
198		Args: map[string]string{
199			"output": outPath.String(),
200			"files":  strings.Join(wrap("-f ", hidlLintOutputs.Strings(), ""), " "),
201		},
202	})
203}
204
205func (m *allHidlLintsSingleton) MakeVars(ctx android.MakeVarsContext) {
206	ctx.Strict("ALL_HIDL_LINTS_ZIP", m.outPath)
207}
208
209type hidlGenProperties struct {
210	Language       string
211	FqName         string
212	Root           string
213	Interfaces     []string
214	Inputs         []string
215	Outputs        []string
216	Apex_available []string
217}
218
219type hidlGenRule struct {
220	android.ModuleBase
221
222	properties hidlGenProperties
223
224	genOutputDir android.Path
225	genInputs    android.Paths
226	genOutputs   android.WritablePaths
227}
228
229var _ android.SourceFileProducer = (*hidlGenRule)(nil)
230var _ genrule.SourceFileGenerator = (*hidlGenRule)(nil)
231
232func (g *hidlGenRule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
233	g.genOutputDir = android.PathForModuleGen(ctx)
234
235	for _, input := range g.properties.Inputs {
236		g.genInputs = append(g.genInputs, android.PathForModuleSrc(ctx, input))
237	}
238
239	var interfaces []string
240	for _, src := range g.properties.Inputs {
241		if strings.HasSuffix(src, ".hal") && strings.HasPrefix(src, "I") {
242			interfaces = append(interfaces, strings.TrimSuffix(src, ".hal"))
243		}
244	}
245
246	switch g.properties.Language {
247	case "lint":
248		g.genOutputs = append(g.genOutputs, android.PathForModuleGen(ctx, "lint.json"))
249	case "inheritance-hierarchy":
250		for _, intf := range interfaces {
251			g.genOutputs = append(g.genOutputs, android.PathForModuleGen(ctx, intf+"_inheritance_hierarchy.json"))
252		}
253	default:
254		for _, output := range g.properties.Outputs {
255			g.genOutputs = append(g.genOutputs, android.PathForModuleGen(ctx, output))
256		}
257	}
258
259	if g.properties.Language == "vts" && isVtsSpecPackage(ctx.ModuleName()) {
260		vtsList := vtsList(ctx.AConfig())
261		vtsListMutex.Lock()
262		*vtsList = append(*vtsList, g.genOutputs.Paths()...)
263		vtsListMutex.Unlock()
264	}
265
266	var extraOptions []string // including roots
267	var currentPath android.OptionalPath
268	ctx.VisitDirectDeps(func(dep android.Module) {
269		switch t := dep.(type) {
270		case *hidlInterface:
271			extraOptions = append(extraOptions, t.properties.Full_root_option)
272		case *hidlPackageRoot:
273			if currentPath.Valid() {
274				panic(fmt.Sprintf("Expecting only one path, but found %v %v", currentPath, t.getCurrentPath()))
275			}
276
277			currentPath = t.getCurrentPath()
278
279			if t.requireFrozen() {
280				extraOptions = append(extraOptions, "-F")
281			}
282		}
283	})
284
285	extraOptions = android.FirstUniqueStrings(extraOptions)
286
287	inputs := g.genInputs
288	if currentPath.Valid() {
289		inputs = append(inputs, currentPath.Path())
290	}
291
292	rule := hidlRule
293	if g.properties.Language == "java" {
294		rule = hidlSrcJarRule
295	}
296
297	if g.properties.Language == "lint" {
298		ctx.Build(pctx, android.BuildParams{
299			Rule:   lintRule,
300			Inputs: inputs,
301			Output: g.genOutputs[0],
302			Args: map[string]string{
303				"output":  g.genOutputs[0].String(),
304				"fqName":  g.properties.FqName,
305				"options": strings.Join(extraOptions, " "),
306			},
307		})
308
309		return
310	}
311
312	if g.properties.Language == "inheritance-hierarchy" {
313		for i, intf := range interfaces {
314			ctx.Build(pctx, android.BuildParams{
315				Rule:   inheritanceHierarchyRule,
316				Inputs: inputs,
317				Output: g.genOutputs[i],
318				Args: map[string]string{
319					"fqInterface": g.properties.FqName + "::" + intf,
320					"options":     strings.Join(extraOptions, " "),
321				},
322			})
323		}
324
325		return
326	}
327
328	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
329		Rule:            rule,
330		Inputs:          inputs,
331		Output:          g.genOutputs[0],
332		ImplicitOutputs: g.genOutputs[1:],
333		Args: map[string]string{
334			"depfile":  g.genOutputs[0].String() + ".d",
335			"genDir":   g.genOutputDir.String(),
336			"fqName":   g.properties.FqName,
337			"language": g.properties.Language,
338			"options":  strings.Join(extraOptions, " "),
339		},
340	})
341}
342
343func (g *hidlGenRule) GeneratedSourceFiles() android.Paths {
344	return g.genOutputs.Paths()
345}
346
347func (g *hidlGenRule) Srcs() android.Paths {
348	return g.genOutputs.Paths()
349}
350
351func (g *hidlGenRule) GeneratedDeps() android.Paths {
352	return g.genOutputs.Paths()
353}
354
355func (g *hidlGenRule) GeneratedHeaderDirs() android.Paths {
356	return android.Paths{g.genOutputDir}
357}
358
359func (g *hidlGenRule) DepsMutator(ctx android.BottomUpMutatorContext) {
360	ctx.AddDependency(ctx.Module(), nil, g.properties.FqName+hidlInterfaceSuffix)
361	ctx.AddDependency(ctx.Module(), nil, wrap("", g.properties.Interfaces, hidlInterfaceSuffix)...)
362	ctx.AddDependency(ctx.Module(), nil, g.properties.Root)
363
364	ctx.AddReverseDependency(ctx.Module(), nil, hidlMetadataSingletonName)
365}
366
367func hidlGenFactory() android.Module {
368	g := &hidlGenRule{}
369	g.AddProperties(&g.properties)
370	android.InitAndroidModule(g)
371	return g
372}
373
374type vtscProperties struct {
375	Mode        string
376	Type        string
377	SpecName    string // e.g. foo-vts.spec
378	Outputs     []string
379	PackagePath string // e.g. android/hardware/foo/1.0/
380}
381
382type vtscRule struct {
383	android.ModuleBase
384
385	properties vtscProperties
386
387	genOutputDir android.Path
388	genInputDir  android.Path
389	genInputs    android.Paths
390	genOutputs   android.WritablePaths
391}
392
393var _ android.SourceFileProducer = (*vtscRule)(nil)
394var _ genrule.SourceFileGenerator = (*vtscRule)(nil)
395
396func (g *vtscRule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
397	g.genOutputDir = android.PathForModuleGen(ctx)
398
399	ctx.VisitDirectDeps(func(dep android.Module) {
400		if specs, ok := dep.(*hidlGenRule); ok {
401			g.genInputDir = specs.genOutputDir
402			g.genInputs = specs.genOutputs.Paths()
403		}
404	})
405
406	for _, output := range g.properties.Outputs {
407		g.genOutputs = append(g.genOutputs, android.PathForModuleGen(ctx, output))
408	}
409
410	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
411		Rule:    vtsRule,
412		Inputs:  g.genInputs,
413		Outputs: g.genOutputs,
414		Args: map[string]string{
415			"mode":        g.properties.Mode,
416			"type":        g.properties.Type,
417			"inputDir":    g.genInputDir.String(),
418			"genDir":      g.genOutputDir.String(),
419			"packagePath": g.properties.PackagePath,
420		},
421	})
422}
423
424func (g *vtscRule) GeneratedSourceFiles() android.Paths {
425	return g.genOutputs.Paths()
426}
427
428func (g *vtscRule) Srcs() android.Paths {
429	return g.genOutputs.Paths()
430}
431
432func (g *vtscRule) GeneratedDeps() android.Paths {
433	return g.genOutputs.Paths()
434}
435
436func (g *vtscRule) GeneratedHeaderDirs() android.Paths {
437	return android.Paths{g.genOutputDir}
438}
439
440func (g *vtscRule) DepsMutator(ctx android.BottomUpMutatorContext) {
441	ctx.AddDependency(ctx.Module(), nil, g.properties.SpecName)
442}
443
444func vtscFactory() android.Module {
445	g := &vtscRule{}
446	g.AddProperties(&g.properties)
447	android.InitAndroidModule(g)
448	return g
449}
450
451type prebuiltHidlInterfaceProperties struct {
452	// List of interfaces to consider valid, e.g. "vendor.foo.bar@1.0::IFoo" for typo checking
453	// between init.rc, VINTF, and elsewhere. Note that inheritance properties will not be
454	// checked for these (but would be checked in a branch where the actual hidl_interface
455	// exists).
456	Interfaces []string
457}
458
459type prebuiltHidlInterface struct {
460	android.ModuleBase
461
462	properties prebuiltHidlInterfaceProperties
463}
464
465func (p *prebuiltHidlInterface) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
466
467func (p *prebuiltHidlInterface) DepsMutator(ctx android.BottomUpMutatorContext) {
468	ctx.AddReverseDependency(ctx.Module(), nil, hidlMetadataSingletonName)
469}
470
471func prebuiltHidlInterfaceFactory() android.Module {
472	i := &prebuiltHidlInterface{}
473	i.AddProperties(&i.properties)
474	android.InitAndroidModule(i)
475	return i
476}
477
478type hidlInterfaceProperties struct {
479	// Vndk properties for interface library only.
480	cc.VndkProperties
481
482	// List of .hal files which compose this interface.
483	Srcs []string
484
485	// List of hal interface packages that this library depends on.
486	Interfaces []string
487
488	// Package root for this package, must be a prefix of name
489	Root string
490
491	// Unused/deprecated: List of non-TypeDef types declared in types.hal.
492	Types []string
493
494	// Whether to generate the Java library stubs.
495	// Default: true
496	Gen_java *bool
497
498	// Whether to generate a Java library containing constants
499	// expressed by @export annotations in the hal files.
500	Gen_java_constants bool
501
502	// Whether to generate VTS-related testing libraries.
503	Gen_vts *bool
504
505	// example: -randroid.hardware:hardware/interfaces
506	Full_root_option string `blueprint:"mutated"`
507
508	// List of APEX modules this interface can be used in.
509	//
510	// WARNING: HIDL is not fully supported in APEX since VINTF currently doesn't
511	// read files from APEXes (b/130058564).
512	//
513	// "//apex_available:anyapex" is a pseudo APEX name that matches to any APEX.
514	// "//apex_available:platform" refers to non-APEX partitions like "system.img"
515	//
516	// Note, this only applies to C++ libs, Java libs, and Java constant libs. It
517	// does  not apply to VTS targets/adapter targets/fuzzers since these components
518	// should not be shipped on device.
519	Apex_available []string
520
521	// Installs the vendor variant of the module to the /odm partition instead of
522	// the /vendor partition.
523	Odm_available *bool
524}
525
526type hidlInterface struct {
527	android.ModuleBase
528
529	properties hidlInterfaceProperties
530}
531
532func processSources(mctx android.LoadHookContext, srcs []string) ([]string, []string, bool) {
533	var interfaces []string
534	var types []string // hidl-gen only supports types.hal, but don't assume that here
535
536	hasError := false
537
538	for _, v := range srcs {
539		if !strings.HasSuffix(v, ".hal") {
540			mctx.PropertyErrorf("srcs", "Source must be a .hal file: "+v)
541			hasError = true
542			continue
543		}
544
545		name := strings.TrimSuffix(v, ".hal")
546
547		if strings.HasPrefix(name, "I") {
548			baseName := strings.TrimPrefix(name, "I")
549			interfaces = append(interfaces, baseName)
550		} else {
551			types = append(types, name)
552		}
553	}
554
555	return interfaces, types, !hasError
556}
557
558func processDependencies(mctx android.LoadHookContext, interfaces []string) ([]string, []string, bool) {
559	var dependencies []string
560	var javaDependencies []string
561
562	hasError := false
563
564	for _, v := range interfaces {
565		name, err := parseFqName(v)
566		if err != nil {
567			mctx.PropertyErrorf("interfaces", err.Error())
568			hasError = true
569			continue
570		}
571		dependencies = append(dependencies, name.string())
572		javaDependencies = append(javaDependencies, name.javaName())
573	}
574
575	return dependencies, javaDependencies, !hasError
576}
577
578func removeCoreDependencies(mctx android.LoadHookContext, dependencies []string) []string {
579	var ret []string
580
581	for _, i := range dependencies {
582		if !isCorePackage(i) {
583			ret = append(ret, i)
584		}
585	}
586
587	return ret
588}
589
590func hidlInterfaceMutator(mctx android.LoadHookContext, i *hidlInterface) {
591	if !canInterfaceExist(i.ModuleBase.Name()) {
592		mctx.PropertyErrorf("name", "No more HIDL interfaces can be added to Android. Please use AIDL.")
593		return
594	}
595
596	name, err := parseFqName(i.ModuleBase.Name())
597	if err != nil {
598		mctx.PropertyErrorf("name", err.Error())
599	}
600
601	if !name.inPackage(i.properties.Root) {
602		mctx.PropertyErrorf("root", i.properties.Root+" must be a prefix of  "+name.string()+".")
603	}
604	if lookupPackageRoot(i.properties.Root) == nil {
605		mctx.PropertyErrorf("interfaces", `Cannot find package root specification for package `+
606			`root '%s' needed for module '%s'. Either this is a mispelling of the package `+
607			`root, or a new hidl_package_root module needs to be added. For example, you can `+
608			`fix this error by adding the following to <some path>/Android.bp:
609
610hidl_package_root {
611name: "%s",
612// if you want to require <some path>/current.txt for interface versioning
613use_current: true,
614}
615
616This corresponds to the "-r%s:<some path>" option that would be passed into hidl-gen.`,
617			i.properties.Root, name, i.properties.Root, i.properties.Root)
618	}
619
620	interfaces, types, _ := processSources(mctx, i.properties.Srcs)
621
622	if len(interfaces) == 0 && len(types) == 0 {
623		mctx.PropertyErrorf("srcs", "No sources provided.")
624	}
625
626	dependencies, javaDependencies, _ := processDependencies(mctx, i.properties.Interfaces)
627	cppDependencies := removeCoreDependencies(mctx, dependencies)
628
629	if mctx.Failed() {
630		return
631	}
632
633	shouldGenerateLibrary := !isCorePackage(name.string())
634	// explicitly true if not specified to give early warning to devs
635	shouldGenerateJava := proptools.BoolDefault(i.properties.Gen_java, true)
636	shouldGenerateJavaConstants := i.properties.Gen_java_constants
637	shouldGenerateVts := shouldGenerateLibrary && proptools.BoolDefault(i.properties.Gen_vts, true)
638
639	// To generate VTS, hidl_interface must have a core variant.
640	// A module with 'product_specific: true' does not create a core variant.
641	shouldGenerateVts = shouldGenerateVts && !mctx.ProductSpecific()
642
643	var productAvailable *bool
644	if !mctx.ProductSpecific() {
645		productAvailable = proptools.BoolPtr(true)
646	}
647
648	var vendorAvailable *bool
649	if !proptools.Bool(i.properties.Odm_available) {
650		vendorAvailable = proptools.BoolPtr(true)
651	}
652
653	var libraryIfExists []string
654	if shouldGenerateLibrary {
655		libraryIfExists = []string{name.string()}
656	}
657
658	// TODO(b/69002743): remove filegroups
659	mctx.CreateModule(android.FileGroupFactory, &fileGroupProperties{
660		Name: proptools.StringPtr(name.fileGroupName()),
661		Srcs: i.properties.Srcs,
662	})
663
664	mctx.CreateModule(hidlGenFactory, &nameProperties{
665		Name: proptools.StringPtr(name.sourcesName()),
666	}, &hidlGenProperties{
667		Language:   "c++-sources",
668		FqName:     name.string(),
669		Root:       i.properties.Root,
670		Interfaces: i.properties.Interfaces,
671		Inputs:     i.properties.Srcs,
672		Outputs:    concat(wrap(name.dir(), interfaces, "All.cpp"), wrap(name.dir(), types, ".cpp")),
673	})
674	mctx.CreateModule(hidlGenFactory, &nameProperties{
675		Name: proptools.StringPtr(name.headersName()),
676	}, &hidlGenProperties{
677		Language:   "c++-headers",
678		FqName:     name.string(),
679		Root:       i.properties.Root,
680		Interfaces: i.properties.Interfaces,
681		Inputs:     i.properties.Srcs,
682		Outputs: concat(wrap(name.dir()+"I", interfaces, ".h"),
683			wrap(name.dir()+"Bs", interfaces, ".h"),
684			wrap(name.dir()+"BnHw", interfaces, ".h"),
685			wrap(name.dir()+"BpHw", interfaces, ".h"),
686			wrap(name.dir()+"IHw", interfaces, ".h"),
687			wrap(name.dir(), types, ".h"),
688			wrap(name.dir()+"hw", types, ".h")),
689	})
690
691	if shouldGenerateLibrary {
692		mctx.CreateModule(cc.LibraryFactory, &ccProperties{
693			Name:               proptools.StringPtr(name.string()),
694			Host_supported:     proptools.BoolPtr(true),
695			Recovery_available: proptools.BoolPtr(true),
696			Vendor_available:   vendorAvailable,
697			Odm_available:      i.properties.Odm_available,
698			Product_available:  productAvailable,
699			Double_loadable:    proptools.BoolPtr(isDoubleLoadable(name.string())),
700			Defaults:           []string{"hidl-module-defaults"},
701			Generated_sources:  []string{name.sourcesName()},
702			Generated_headers:  []string{name.headersName()},
703			Shared_libs: concat(cppDependencies, []string{
704				"libhidlbase",
705				"liblog",
706				"libutils",
707				"libcutils",
708			}),
709			Export_shared_lib_headers: concat(cppDependencies, []string{
710				"libhidlbase",
711				"libutils",
712			}),
713			Export_generated_headers: []string{name.headersName()},
714			Apex_available:           i.properties.Apex_available,
715			Min_sdk_version:          getMinSdkVersion(name.string()),
716		}, &i.properties.VndkProperties)
717	}
718
719	if shouldGenerateJava {
720		mctx.CreateModule(hidlGenFactory, &nameProperties{
721			Name: proptools.StringPtr(name.javaSourcesName()),
722		}, &hidlGenProperties{
723			Language:   "java",
724			FqName:     name.string(),
725			Root:       i.properties.Root,
726			Interfaces: i.properties.Interfaces,
727			Inputs:     i.properties.Srcs,
728			Outputs:    []string{"srcs.srcjar"},
729		})
730
731		commonJavaProperties := javaProperties{
732			Defaults:    []string{"hidl-java-module-defaults"},
733			Installable: proptools.BoolPtr(true),
734			Srcs:        []string{":" + name.javaSourcesName()},
735
736			// This should ideally be system_current, but android.hidl.base-V1.0-java is used
737			// to build framework, which is used to build system_current.  Use core_current
738			// plus hwbinder.stubs, which together form a subset of system_current that does
739			// not depend on framework.
740			Sdk_version:     proptools.StringPtr("core_current"),
741			Libs:            []string{"hwbinder.stubs"},
742			Apex_available:  i.properties.Apex_available,
743			Min_sdk_version: getMinSdkVersion(name.string()),
744		}
745
746		mctx.CreateModule(java.LibraryFactory, &javaProperties{
747			Name:        proptools.StringPtr(name.javaName()),
748			Static_libs: javaDependencies,
749		}, &commonJavaProperties)
750		mctx.CreateModule(java.LibraryFactory, &javaProperties{
751			Name: proptools.StringPtr(name.javaSharedName()),
752			Libs: javaDependencies,
753		}, &commonJavaProperties)
754	}
755
756	if shouldGenerateJavaConstants {
757		mctx.CreateModule(hidlGenFactory, &nameProperties{
758			Name: proptools.StringPtr(name.javaConstantsSourcesName()),
759		}, &hidlGenProperties{
760			Language:   "java-constants",
761			FqName:     name.string(),
762			Root:       i.properties.Root,
763			Interfaces: i.properties.Interfaces,
764			Inputs:     i.properties.Srcs,
765			Outputs:    []string{name.sanitizedDir() + "Constants.java"},
766		})
767		mctx.CreateModule(java.LibraryFactory, &javaProperties{
768			Name:            proptools.StringPtr(name.javaConstantsName()),
769			Defaults:        []string{"hidl-java-module-defaults"},
770			Sdk_version:     proptools.StringPtr("core_current"),
771			Srcs:            []string{":" + name.javaConstantsSourcesName()},
772			Apex_available:  i.properties.Apex_available,
773			Min_sdk_version: getMinSdkVersion(name.string()),
774		})
775	}
776
777	mctx.CreateModule(hidlGenFactory, &nameProperties{
778		Name: proptools.StringPtr(name.adapterHelperSourcesName()),
779	}, &hidlGenProperties{
780		Language:   "c++-adapter-sources",
781		FqName:     name.string(),
782		Root:       i.properties.Root,
783		Interfaces: i.properties.Interfaces,
784		Inputs:     i.properties.Srcs,
785		Outputs:    wrap(name.dir()+"A", concat(interfaces, types), ".cpp"),
786	})
787	mctx.CreateModule(hidlGenFactory, &nameProperties{
788		Name: proptools.StringPtr(name.adapterHelperHeadersName()),
789	}, &hidlGenProperties{
790		Language:   "c++-adapter-headers",
791		FqName:     name.string(),
792		Root:       i.properties.Root,
793		Interfaces: i.properties.Interfaces,
794		Inputs:     i.properties.Srcs,
795		Outputs:    wrap(name.dir()+"A", concat(interfaces, types), ".h"),
796	})
797
798	mctx.CreateModule(cc.LibraryFactory, &ccProperties{
799		Name:              proptools.StringPtr(name.adapterHelperName()),
800		Vendor_available:  vendorAvailable,
801		Odm_available:     i.properties.Odm_available,
802		Product_available: productAvailable,
803		Defaults:          []string{"hidl-module-defaults"},
804		Generated_sources: []string{name.adapterHelperSourcesName()},
805		Generated_headers: []string{name.adapterHelperHeadersName()},
806		Shared_libs: []string{
807			"libbase",
808			"libcutils",
809			"libhidlbase",
810			"liblog",
811			"libutils",
812		},
813		Static_libs: concat([]string{
814			"libhidladapter",
815		}, wrap("", dependencies, "-adapter-helper"), cppDependencies, libraryIfExists),
816		Export_shared_lib_headers: []string{
817			"libhidlbase",
818		},
819		Export_static_lib_headers: concat([]string{
820			"libhidladapter",
821		}, wrap("", dependencies, "-adapter-helper"), cppDependencies, libraryIfExists),
822		Export_generated_headers: []string{name.adapterHelperHeadersName()},
823		Group_static_libs:        proptools.BoolPtr(true),
824	})
825	mctx.CreateModule(hidlGenFactory, &nameProperties{
826		Name: proptools.StringPtr(name.adapterSourcesName()),
827	}, &hidlGenProperties{
828		Language:   "c++-adapter-main",
829		FqName:     name.string(),
830		Root:       i.properties.Root,
831		Interfaces: i.properties.Interfaces,
832		Inputs:     i.properties.Srcs,
833		Outputs:    []string{"main.cpp"},
834	})
835	mctx.CreateModule(cc.TestFactory, &ccProperties{
836		Name:              proptools.StringPtr(name.adapterName()),
837		Generated_sources: []string{name.adapterSourcesName()},
838		Shared_libs: []string{
839			"libbase",
840			"libcutils",
841			"libhidlbase",
842			"liblog",
843			"libutils",
844		},
845		Static_libs: concat([]string{
846			"libhidladapter",
847			name.adapterHelperName(),
848		}, wrap("", dependencies, "-adapter-helper"), cppDependencies, libraryIfExists),
849		Group_static_libs: proptools.BoolPtr(true),
850	})
851
852	if shouldGenerateVts {
853		vtsSpecs := concat(wrap(name.dir(), interfaces, ".vts"), wrap(name.dir(), types, ".vts"))
854
855		mctx.CreateModule(hidlGenFactory, &nameProperties{
856			Name: proptools.StringPtr(name.vtsSpecName()),
857		}, &hidlGenProperties{
858			Language:   "vts",
859			FqName:     name.string(),
860			Root:       i.properties.Root,
861			Interfaces: i.properties.Interfaces,
862			Inputs:     i.properties.Srcs,
863			Outputs:    vtsSpecs,
864		})
865
866		mctx.CreateModule(vtscFactory, &nameProperties{
867			Name: proptools.StringPtr(name.vtsDriverSourcesName()),
868		}, &vtscProperties{
869			Mode:        "DRIVER",
870			Type:        "SOURCE",
871			SpecName:    name.vtsSpecName(),
872			Outputs:     wrap("", vtsSpecs, ".cpp"),
873			PackagePath: name.dir(),
874		})
875		mctx.CreateModule(vtscFactory, &nameProperties{
876			Name: proptools.StringPtr(name.vtsDriverHeadersName()),
877		}, &vtscProperties{
878			Mode:        "DRIVER",
879			Type:        "HEADER",
880			SpecName:    name.vtsSpecName(),
881			Outputs:     wrap("", vtsSpecs, ".h"),
882			PackagePath: name.dir(),
883		})
884		mctx.CreateModule(cc.LibraryFactory, &ccProperties{
885			Name:                      proptools.StringPtr(name.vtsDriverName()),
886			Defaults:                  []string{"VtsHalDriverDefaults"},
887			Generated_sources:         []string{name.vtsDriverSourcesName()},
888			Generated_headers:         []string{name.vtsDriverHeadersName()},
889			Export_generated_headers:  []string{name.vtsDriverHeadersName()},
890			Shared_libs:               wrap("", cppDependencies, "-vts.driver"),
891			Export_shared_lib_headers: wrap("", cppDependencies, "-vts.driver"),
892			Static_libs:               concat(cppDependencies, libraryIfExists),
893
894			// TODO(b/126244142)
895			Cflags: []string{"-Wno-unused-variable"},
896		})
897
898		mctx.CreateModule(vtscFactory, &nameProperties{
899			Name: proptools.StringPtr(name.vtsProfilerSourcesName()),
900		}, &vtscProperties{
901			Mode:        "PROFILER",
902			Type:        "SOURCE",
903			SpecName:    name.vtsSpecName(),
904			Outputs:     wrap("", vtsSpecs, ".cpp"),
905			PackagePath: name.dir(),
906		})
907		mctx.CreateModule(vtscFactory, &nameProperties{
908			Name: proptools.StringPtr(name.vtsProfilerHeadersName()),
909		}, &vtscProperties{
910			Mode:        "PROFILER",
911			Type:        "HEADER",
912			SpecName:    name.vtsSpecName(),
913			Outputs:     wrap("", vtsSpecs, ".h"),
914			PackagePath: name.dir(),
915		})
916		mctx.CreateModule(cc.LibraryFactory, &ccProperties{
917			Name:                      proptools.StringPtr(name.vtsProfilerName()),
918			Defaults:                  []string{"VtsHalProfilerDefaults"},
919			Generated_sources:         []string{name.vtsProfilerSourcesName()},
920			Generated_headers:         []string{name.vtsProfilerHeadersName()},
921			Export_generated_headers:  []string{name.vtsProfilerHeadersName()},
922			Shared_libs:               wrap("", cppDependencies, "-vts.profiler"),
923			Export_shared_lib_headers: wrap("", cppDependencies, "-vts.profiler"),
924			Static_libs:               concat(cppDependencies, libraryIfExists),
925
926			// TODO(b/126244142)
927			Cflags: []string{"-Wno-unused-variable"},
928		})
929
930		specDependencies := append(cppDependencies, name.string())
931		mctx.CreateModule(cc.FuzzFactory, &ccProperties{
932			Name:        proptools.StringPtr(name.vtsFuzzerName()),
933			Defaults:    []string{"vts_proto_fuzzer_default"},
934			Shared_libs: []string{name.vtsDriverName()},
935			Cflags: []string{
936				"-DSTATIC_TARGET_FQ_NAME=" + name.string(),
937				"-DSTATIC_SPEC_DATA=" + strings.Join(specDependencies, ":"),
938			},
939		}, &fuzzProperties{
940			Data: wrap(":", specDependencies, "-vts.spec"),
941			Fuzz_config: &fuzzConfig{
942				Fuzz_on_haiku_device: proptools.BoolPtr(isFuzzerEnabled(name.vtsFuzzerName())),
943			},
944		})
945	}
946
947	mctx.CreateModule(hidlGenFactory, &nameProperties{
948		Name: proptools.StringPtr(name.lintName()),
949	}, &hidlGenProperties{
950		Language:   "lint",
951		FqName:     name.string(),
952		Root:       i.properties.Root,
953		Interfaces: i.properties.Interfaces,
954		Inputs:     i.properties.Srcs,
955	})
956
957	mctx.CreateModule(hidlGenFactory, &nameProperties{
958		Name: proptools.StringPtr(name.inheritanceHierarchyName()),
959	}, &hidlGenProperties{
960		Language:   "inheritance-hierarchy",
961		FqName:     name.string(),
962		Root:       i.properties.Root,
963		Interfaces: i.properties.Interfaces,
964		Inputs:     i.properties.Srcs,
965	})
966}
967
968func (h *hidlInterface) Name() string {
969	return h.ModuleBase.Name() + hidlInterfaceSuffix
970}
971func (h *hidlInterface) GenerateAndroidBuildActions(ctx android.ModuleContext) {
972	visited := false
973	ctx.VisitDirectDeps(func(dep android.Module) {
974		if r, ok := dep.(*hidlPackageRoot); ok {
975			if visited {
976				panic("internal error, multiple dependencies found but only one added")
977			}
978			visited = true
979			h.properties.Full_root_option = r.getFullPackageRoot()
980		}
981	})
982	if !visited {
983		panic("internal error, no dependencies found but dependency added")
984	}
985
986}
987func (h *hidlInterface) DepsMutator(ctx android.BottomUpMutatorContext) {
988	ctx.AddDependency(ctx.Module(), nil, h.properties.Root)
989}
990
991func hidlInterfaceFactory() android.Module {
992	i := &hidlInterface{}
993	i.AddProperties(&i.properties)
994	android.InitAndroidModule(i)
995	android.AddLoadHook(i, func(ctx android.LoadHookContext) { hidlInterfaceMutator(ctx, i) })
996
997	return i
998}
999
1000var minSdkVersion = map[string]string{
1001	"android.frameworks.bufferhub@1.0":          "29",
1002	"android.hardware.audio.common@5.0":         "30",
1003	"android.hardware.bluetooth.a2dp@1.0":       "30",
1004	"android.hardware.bluetooth.audio@2.0":      "30",
1005	"android.hardware.bluetooth@1.0":            "30",
1006	"android.hardware.bluetooth@1.1":            "30",
1007	"android.hardware.cas.native@1.0":           "29",
1008	"android.hardware.cas@1.0":                  "29",
1009	"android.hardware.graphics.allocator@2.0":   "29",
1010	"android.hardware.graphics.allocator@3.0":   "29",
1011	"android.hardware.graphics.allocator@4.0":   "29",
1012	"android.hardware.graphics.bufferqueue@1.0": "29",
1013	"android.hardware.graphics.bufferqueue@2.0": "29",
1014	"android.hardware.graphics.common@1.0":      "29",
1015	"android.hardware.graphics.common@1.1":      "29",
1016	"android.hardware.graphics.common@1.2":      "29",
1017	"android.hardware.graphics.mapper@2.0":      "29",
1018	"android.hardware.graphics.mapper@2.1":      "29",
1019	"android.hardware.graphics.mapper@3.0":      "29",
1020	"android.hardware.graphics.mapper@4.0":      "29",
1021	"android.hardware.media.bufferpool@2.0":     "29",
1022	"android.hardware.media.c2@1.0":             "29",
1023	"android.hardware.media.c2@1.1":             "29",
1024	"android.hardware.media.c2@1.2":             "29",
1025	"android.hardware.media.omx@1.0":            "29",
1026	"android.hardware.media@1.0":                "29",
1027	"android.hardware.neuralnetworks@1.0":       "30",
1028	"android.hardware.neuralnetworks@1.1":       "30",
1029	"android.hardware.neuralnetworks@1.2":       "30",
1030	"android.hardware.neuralnetworks@1.3":       "30",
1031	"android.hardware.wifi@1.0":                 "30",
1032	"android.hardware.wifi@1.1":                 "30",
1033	"android.hardware.wifi@1.2":                 "30",
1034	"android.hardware.wifi@1.3":                 "30",
1035	"android.hardware.wifi@1.4":                 "30",
1036	"android.hardware.wifi@1.5":                 "30",
1037	"android.hardware.wifi.hostapd@1.0":         "30",
1038	"android.hardware.wifi.hostapd@1.1":         "30",
1039	"android.hardware.wifi.hostapd@1.2":         "30",
1040	"android.hardware.wifi.hostapd@1.3":         "30",
1041	"android.hardware.wifi.supplicant@1.0":      "30",
1042	"android.hardware.wifi.supplicant@1.1":      "30",
1043	"android.hardware.wifi.supplicant@1.2":      "30",
1044	"android.hardware.wifi.supplicant@1.3":      "30",
1045	"android.hardware.wifi.supplicant@1.4":      "30",
1046	"android.hidl.allocator@1.0":                "29",
1047	"android.hidl.manager@1.0":                  "30",
1048	"android.hidl.manager@1.1":                  "30",
1049	"android.hidl.manager@1.2":                  "30",
1050	"android.hidl.memory.token@1.0":             "29",
1051	"android.hidl.memory@1.0":                   "29",
1052	"android.hidl.safe_union@1.0":               "29",
1053	"android.hidl.token@1.0":                    "29",
1054}
1055
1056func getMinSdkVersion(name string) *string {
1057	if ver, ok := minSdkVersion[name]; ok {
1058		return proptools.StringPtr(ver)
1059	}
1060	return nil
1061}
1062
1063var doubleLoadablePackageNames = []string{
1064	"android.frameworks.bufferhub@1.0",
1065	"android.hardware.cas@1.0",
1066	"android.hardware.cas.native@1.0",
1067	"android.hardware.configstore@",
1068	"android.hardware.drm@",
1069	"android.hardware.graphics.allocator@",
1070	"android.hardware.graphics.bufferqueue@",
1071	"android.hardware.media@",
1072	"android.hardware.media.bufferpool@",
1073	"android.hardware.media.c2@",
1074	"android.hardware.media.omx@",
1075	"android.hardware.memtrack@1.0",
1076	"android.hardware.neuralnetworks@",
1077	"android.hidl.allocator@",
1078	"android.hidl.token@",
1079	"android.system.suspend@1.0",
1080}
1081
1082func isDoubleLoadable(name string) bool {
1083	for _, pkgname := range doubleLoadablePackageNames {
1084		if strings.HasPrefix(name, pkgname) {
1085			return true
1086		}
1087	}
1088	return false
1089}
1090
1091// packages in libhidlbase
1092var coreDependencyPackageNames = []string{
1093	"android.hidl.base@",
1094	"android.hidl.manager@",
1095}
1096
1097func isCorePackage(name string) bool {
1098	for _, pkgname := range coreDependencyPackageNames {
1099		if strings.HasPrefix(name, pkgname) {
1100			return true
1101		}
1102	}
1103	return false
1104}
1105
1106var fuzzerPackageNameBlacklist = []string{
1107	"android.hardware.keymaster@", // to avoid deleteAllKeys()
1108	// Same-process HALs are always opened in the same process as their client.
1109	// So stability guarantees don't apply to them, e.g. it's OK to crash on
1110	// NULL input from client. Disable corresponding fuzzers as they create too
1111	// much noise.
1112	"android.hardware.graphics.mapper@",
1113	"android.hardware.renderscript@",
1114	"android.hidl.memory@",
1115}
1116
1117func isFuzzerEnabled(name string) bool {
1118	// TODO(151338797): re-enable fuzzers
1119	return false
1120}
1121
1122// TODO(b/126383715): centralize this logic/support filtering in core VTS build
1123var coreVtsSpecs = []string{
1124	"android.frameworks.",
1125	"android.hardware.",
1126	"android.hidl.",
1127	"android.system.",
1128}
1129
1130func isVtsSpecPackage(name string) bool {
1131	for _, pkgname := range coreVtsSpecs {
1132		if strings.HasPrefix(name, pkgname) {
1133			return true
1134		}
1135	}
1136	return false
1137}
1138
1139var vtsListKey = android.NewOnceKey("vtsList")
1140
1141func vtsList(config android.Config) *android.Paths {
1142	return config.Once(vtsListKey, func() interface{} {
1143		return &android.Paths{}
1144	}).(*android.Paths)
1145}
1146
1147var vtsListMutex sync.Mutex
1148
1149func makeVarsProvider(ctx android.MakeVarsContext) {
1150	vtsList := vtsList(ctx.Config()).Strings()
1151	sort.Strings(vtsList)
1152
1153	ctx.Strict("VTS_SPEC_FILE_LIST", strings.Join(vtsList, " "))
1154}
1155
1156func canInterfaceExist(name string) bool {
1157	if strings.HasPrefix(name, "android.") {
1158		return allAospHidlInterfaces[name]
1159	}
1160
1161	return true
1162}
1163
1164var allAospHidlInterfaces = map[string]bool{
1165	"android.frameworks.automotive.display@1.0":         true,
1166	"android.frameworks.bufferhub@1.0":                  true,
1167	"android.frameworks.cameraservice.common@2.0":       true,
1168	"android.frameworks.cameraservice.device@2.0":       true,
1169	"android.frameworks.cameraservice.device@2.1":       true,
1170	"android.frameworks.cameraservice.service@2.0":      true,
1171	"android.frameworks.cameraservice.service@2.1":      true,
1172	"android.frameworks.cameraservice.service@2.2":      true,
1173	"android.frameworks.displayservice@1.0":             true,
1174	"android.frameworks.schedulerservice@1.0":           true,
1175	"android.frameworks.sensorservice@1.0":              true,
1176	"android.frameworks.stats@1.0":                      true,
1177	"android.frameworks.vr.composer@1.0":                true,
1178	"android.frameworks.vr.composer@2.0":                true,
1179	"android.hardware.atrace@1.0":                       true,
1180	"android.hardware.audio@2.0":                        true,
1181	"android.hardware.audio@4.0":                        true,
1182	"android.hardware.audio@5.0":                        true,
1183	"android.hardware.audio@6.0":                        true,
1184	"android.hardware.audio@7.0":                        true,
1185	"android.hardware.audio.common@2.0":                 true,
1186	"android.hardware.audio.common@4.0":                 true,
1187	"android.hardware.audio.common@5.0":                 true,
1188	"android.hardware.audio.common@6.0":                 true,
1189	"android.hardware.audio.common@7.0":                 true,
1190	"android.hardware.audio.effect@2.0":                 true,
1191	"android.hardware.audio.effect@4.0":                 true,
1192	"android.hardware.audio.effect@5.0":                 true,
1193	"android.hardware.audio.effect@6.0":                 true,
1194	"android.hardware.audio.effect@7.0":                 true,
1195	"android.hardware.authsecret@1.0":                   true,
1196	"android.hardware.automotive.audiocontrol@1.0":      true,
1197	"android.hardware.automotive.audiocontrol@2.0":      true,
1198	"android.hardware.automotive.can@1.0":               true,
1199	"android.hardware.automotive.evs@1.0":               true,
1200	"android.hardware.automotive.evs@1.1":               true,
1201	"android.hardware.automotive.sv@1.0":                true,
1202	"android.hardware.automotive.vehicle@2.0":           true,
1203	"android.hardware.biometrics.face@1.0":              true,
1204	"android.hardware.biometrics.fingerprint@2.1":       true,
1205	"android.hardware.biometrics.fingerprint@2.2":       true,
1206	"android.hardware.biometrics.fingerprint@2.3":       true,
1207	"android.hardware.bluetooth@1.0":                    true,
1208	"android.hardware.bluetooth@1.1":                    true,
1209	"android.hardware.bluetooth.a2dp@1.0":               true,
1210	"android.hardware.bluetooth.audio@2.0":              true,
1211	"android.hardware.bluetooth.audio@2.1":              true,
1212	"android.hardware.boot@1.0":                         true,
1213	"android.hardware.boot@1.1":                         true,
1214	"android.hardware.boot@1.2":                         true,
1215	"android.hardware.broadcastradio@1.0":               true,
1216	"android.hardware.broadcastradio@1.1":               true,
1217	"android.hardware.broadcastradio@2.0":               true,
1218	"android.hardware.camera.common@1.0":                true,
1219	"android.hardware.camera.device@1.0":                true,
1220	"android.hardware.camera.device@3.2":                true,
1221	"android.hardware.camera.device@3.3":                true,
1222	"android.hardware.camera.device@3.4":                true,
1223	"android.hardware.camera.device@3.5":                true,
1224	"android.hardware.camera.device@3.6":                true,
1225	"android.hardware.camera.device@3.7":                true,
1226	"android.hardware.camera.metadata@3.2":              true,
1227	"android.hardware.camera.metadata@3.3":              true,
1228	"android.hardware.camera.metadata@3.4":              true,
1229	"android.hardware.camera.metadata@3.5":              true,
1230	"android.hardware.camera.metadata@3.6":              true,
1231	"android.hardware.camera.provider@2.4":              true,
1232	"android.hardware.camera.provider@2.5":              true,
1233	"android.hardware.camera.provider@2.6":              true,
1234	"android.hardware.camera.provider@2.7":              true,
1235	"android.hardware.cas@1.0":                          true,
1236	"android.hardware.cas@1.1":                          true,
1237	"android.hardware.cas@1.2":                          true,
1238	"android.hardware.cas.native@1.0":                   true,
1239	"android.hardware.configstore@1.0":                  true,
1240	"android.hardware.configstore@1.1":                  true,
1241	"android.hardware.confirmationui@1.0":               true,
1242	"android.hardware.contexthub@1.0":                   true,
1243	"android.hardware.contexthub@1.1":                   true,
1244	"android.hardware.contexthub@1.2":                   true,
1245	"android.hardware.drm@1.0":                          true,
1246	"android.hardware.drm@1.1":                          true,
1247	"android.hardware.drm@1.2":                          true,
1248	"android.hardware.drm@1.3":                          true,
1249	"android.hardware.drm@1.4":                          true,
1250	"android.hardware.dumpstate@1.0":                    true,
1251	"android.hardware.dumpstate@1.1":                    true,
1252	"android.hardware.fastboot@1.0":                     true,
1253	"android.hardware.fastboot@1.1":                     true,
1254	"android.hardware.gatekeeper@1.0":                   true,
1255	"android.hardware.gnss@1.0":                         true,
1256	"android.hardware.gnss@1.1":                         true,
1257	"android.hardware.gnss@2.0":                         true,
1258	"android.hardware.gnss@2.1":                         true,
1259	"android.hardware.gnss.measurement_corrections@1.0": true,
1260	"android.hardware.gnss.measurement_corrections@1.1": true,
1261	"android.hardware.gnss.visibility_control@1.0":      true,
1262	"android.hardware.graphics.allocator@2.0":           true,
1263	"android.hardware.graphics.allocator@3.0":           true,
1264	"android.hardware.graphics.allocator@4.0":           true,
1265	"android.hardware.graphics.bufferqueue@1.0":         true,
1266	"android.hardware.graphics.bufferqueue@2.0":         true,
1267	"android.hardware.graphics.common@1.0":              true,
1268	"android.hardware.graphics.common@1.1":              true,
1269	"android.hardware.graphics.common@1.2":              true,
1270	"android.hardware.graphics.composer@2.1":            true,
1271	"android.hardware.graphics.composer@2.2":            true,
1272	"android.hardware.graphics.composer@2.3":            true,
1273	"android.hardware.graphics.composer@2.4":            true,
1274	"android.hardware.graphics.mapper@2.0":              true,
1275	"android.hardware.graphics.mapper@2.1":              true,
1276	"android.hardware.graphics.mapper@3.0":              true,
1277	"android.hardware.graphics.mapper@4.0":              true,
1278	"android.hardware.health@1.0":                       true,
1279	"android.hardware.health@2.0":                       true,
1280	"android.hardware.health@2.1":                       true,
1281	"android.hardware.health.storage@1.0":               true,
1282	"android.hardware.input.classifier@1.0":             true,
1283	"android.hardware.input.common@1.0":                 true,
1284	"android.hardware.ir@1.0":                           true,
1285	"android.hardware.keymaster@3.0":                    true,
1286	"android.hardware.keymaster@4.0":                    true,
1287	"android.hardware.keymaster@4.1":                    true,
1288	"android.hardware.light@2.0":                        true,
1289	"android.hardware.media@1.0":                        true,
1290	"android.hardware.media.bufferpool@1.0":             true,
1291	"android.hardware.media.bufferpool@2.0":             true,
1292	"android.hardware.media.c2@1.0":                     true,
1293	"android.hardware.media.c2@1.1":                     true,
1294	"android.hardware.media.c2@1.2":                     true,
1295	"android.hardware.media.omx@1.0":                    true,
1296	"android.hardware.memtrack@1.0":                     true,
1297	"android.hardware.neuralnetworks@1.0":               true,
1298	"android.hardware.neuralnetworks@1.1":               true,
1299	"android.hardware.neuralnetworks@1.2":               true,
1300	"android.hardware.neuralnetworks@1.3":               true,
1301	"android.hardware.nfc@1.0":                          true,
1302	"android.hardware.nfc@1.1":                          true,
1303	"android.hardware.nfc@1.2":                          true,
1304	"android.hardware.oemlock@1.0":                      true,
1305	"android.hardware.power@1.0":                        true,
1306	"android.hardware.power@1.1":                        true,
1307	"android.hardware.power@1.2":                        true,
1308	"android.hardware.power@1.3":                        true,
1309	"android.hardware.power.stats@1.0":                  true,
1310	"android.hardware.radio@1.0":                        true,
1311	"android.hardware.radio@1.1":                        true,
1312	"android.hardware.radio@1.2":                        true,
1313	"android.hardware.radio@1.3":                        true,
1314	"android.hardware.radio@1.4":                        true,
1315	"android.hardware.radio@1.5":                        true,
1316	"android.hardware.radio@1.6":                        true,
1317	"android.hardware.radio.config@1.0":                 true,
1318	"android.hardware.radio.config@1.1":                 true,
1319	"android.hardware.radio.config@1.2":                 true,
1320	"android.hardware.radio.config@1.3":                 true,
1321	"android.hardware.radio.deprecated@1.0":             true,
1322	"android.hardware.renderscript@1.0":                 true,
1323	"android.hardware.secure_element@1.0":               true,
1324	"android.hardware.secure_element@1.1":               true,
1325	"android.hardware.secure_element@1.2":               true,
1326	"android.hardware.sensors@1.0":                      true,
1327	"android.hardware.sensors@2.0":                      true,
1328	"android.hardware.sensors@2.1":                      true,
1329	"android.hardware.soundtrigger@2.0":                 true,
1330	"android.hardware.soundtrigger@2.1":                 true,
1331	"android.hardware.soundtrigger@2.2":                 true,
1332	"android.hardware.soundtrigger@2.3":                 true,
1333	"android.hardware.soundtrigger@2.4":                 true,
1334	"android.hardware.tests.bar@1.0":                    true,
1335	"android.hardware.tests.baz@1.0":                    true,
1336	"android.hardware.tests.expression@1.0":             true,
1337	"android.hardware.tests.extension.light@2.0":        true,
1338	"android.hardware.tests.foo@1.0":                    true,
1339	"android.hardware.tests.hash@1.0":                   true,
1340	"android.hardware.tests.inheritance@1.0":            true,
1341	"android.hardware.tests.lazy@1.0":                   true,
1342	"android.hardware.tests.lazy@1.1":                   true,
1343	"android.hardware.tests.libhwbinder@1.0":            true,
1344	"android.hardware.tests.memory@1.0":                 true,
1345	"android.hardware.tests.memory@2.0":                 true,
1346	"android.hardware.tests.msgq@1.0":                   true,
1347	"android.hardware.tests.multithread@1.0":            true,
1348	"android.hardware.tests.safeunion@1.0":              true,
1349	"android.hardware.tests.safeunion.cpp@1.0":          true,
1350	"android.hardware.tests.trie@1.0":                   true,
1351	"android.hardware.tetheroffload.config@1.0":         true,
1352	"android.hardware.tetheroffload.control@1.0":        true,
1353	"android.hardware.tetheroffload.control@1.1":        true,
1354	"android.hardware.thermal@1.0":                      true,
1355	"android.hardware.thermal@1.1":                      true,
1356	"android.hardware.thermal@2.0":                      true,
1357	"android.hardware.tv.cec@1.0":                       true,
1358	"android.hardware.tv.cec@1.1":                       true,
1359	"android.hardware.tv.input@1.0":                     true,
1360	"android.hardware.tv.tuner@1.0":                     true,
1361	"android.hardware.tv.tuner@1.1":                     true,
1362	"android.hardware.usb@1.0":                          true,
1363	"android.hardware.usb@1.1":                          true,
1364	"android.hardware.usb@1.2":                          true,
1365	"android.hardware.usb@1.3":                          true,
1366	"android.hardware.usb.gadget@1.0":                   true,
1367	"android.hardware.usb.gadget@1.1":                   true,
1368	"android.hardware.usb.gadget@1.2":                   true,
1369	"android.hardware.vibrator@1.0":                     true,
1370	"android.hardware.vibrator@1.1":                     true,
1371	"android.hardware.vibrator@1.2":                     true,
1372	"android.hardware.vibrator@1.3":                     true,
1373	"android.hardware.vr@1.0":                           true,
1374	"android.hardware.weaver@1.0":                       true,
1375	"android.hardware.wifi@1.0":                         true,
1376	"android.hardware.wifi@1.1":                         true,
1377	"android.hardware.wifi@1.2":                         true,
1378	"android.hardware.wifi@1.3":                         true,
1379	"android.hardware.wifi@1.4":                         true,
1380	"android.hardware.wifi@1.5":                         true,
1381	"android.hardware.wifi.hostapd@1.0":                 true,
1382	"android.hardware.wifi.hostapd@1.1":                 true,
1383	"android.hardware.wifi.hostapd@1.2":                 true,
1384	"android.hardware.wifi.hostapd@1.3":                 true,
1385	"android.hardware.wifi.offload@1.0":                 true,
1386	"android.hardware.wifi.supplicant@1.0":              true,
1387	"android.hardware.wifi.supplicant@1.1":              true,
1388	"android.hardware.wifi.supplicant@1.2":              true,
1389	"android.hardware.wifi.supplicant@1.3":              true,
1390	"android.hardware.wifi.supplicant@1.4":              true,
1391	"android.hidl.allocator@1.0":                        true,
1392	"android.hidl.base@1.0":                             true,
1393	"android.hidl.manager@1.0":                          true,
1394	"android.hidl.manager@1.1":                          true,
1395	"android.hidl.manager@1.2":                          true,
1396	"android.hidl.memory@1.0":                           true,
1397	"android.hidl.memory.block@1.0":                     true,
1398	"android.hidl.memory.token@1.0":                     true,
1399	"android.hidl.safe_union@1.0":                       true,
1400	"android.hidl.token@1.0":                            true,
1401	"android.system.net.netd@1.0":                       true,
1402	"android.system.net.netd@1.1":                       true,
1403	"android.system.suspend@1.0":                        true,
1404	"android.system.wifi.keystore@1.0":                  true,
1405}
1406