Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a37718c authored by Colin Cross's avatar Colin Cross
Browse files

Convert ModuleProvder to generic providers API

Convert all of the callers of ModuleProvider/ModuleHasProvider to use the
type-safe android.SingletonModuleProvider API.

Bug: 316410648
Test: builds
Change-Id: I6f11638546b64749e451cebbf33140248dc1d193
parent 313aa547
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ func TestAconfigDeclarations(t *testing.T) {
	module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule)

	// Check that the provider has the right contents
	depData := result.ModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData)
	depData, _ := android.SingletonModuleProvider(result, module, DeclarationsProviderKey)
	android.AssertStringEquals(t, "package", depData.Package, "com.example.package")
	android.AssertStringEquals(t, "container", depData.Container, "com.android.foo")
	if !strings.HasSuffix(depData.IntermediateCacheOutputPath.String(), "/intermediate.pb") {
+1 −1
Original line number Diff line number Diff line
@@ -38,6 +38,6 @@ func TestAconfigValueSet(t *testing.T) {
	module := result.ModuleForTests("module_name", "").Module().(*ValueSetModule)

	// Check that the provider has the right contents
	depData := result.ModuleProvider(module, valueSetProviderKey).(valueSetProviderData)
	depData, _ := android.SingletonModuleProvider(result, module, valueSetProviderKey)
	android.AssertStringEquals(t, "AvailablePackages", "blah.aconfig_values", depData.AvailablePackages["foo.package"][0].String())
}
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ func TestAconfigValues(t *testing.T) {
	module := result.ModuleForTests("module_name", "").Module().(*ValuesModule)

	// Check that the provider has the right contents
	depData := result.ModuleProvider(module, valuesProviderKey).(valuesProviderData)
	depData, _ := android.SingletonModuleProvider(result, module, valuesProviderKey)
	android.AssertStringEquals(t, "package", "foo.package", depData.Package)
	android.AssertPathsEndWith(t, "srcs", []string{"blah.aconfig_values"}, depData.Values)
}
+2 −2
Original line number Diff line number Diff line
@@ -37,10 +37,10 @@ func (this *allAconfigDeclarationsSingleton) GenerateBuildActions(ctx android.Si
	// Find all of the aconfig_declarations modules
	var cacheFiles android.Paths
	ctx.VisitAllModules(func(module android.Module) {
		if !ctx.ModuleHasProvider(module, DeclarationsProviderKey) {
		decl, ok := android.SingletonModuleProvider(ctx, module, DeclarationsProviderKey)
		if !ok {
			return
		}
		decl := ctx.ModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData)
		cacheFiles = append(cacheFiles, decl.IntermediateCacheOutputPath)
	})

+2 −2
Original line number Diff line number Diff line
@@ -30,10 +30,10 @@ func (this *exportedJavaDeclarationsLibrarySingleton) GenerateBuildActions(ctx a
	// Find all of the aconfig_declarations modules
	var cacheFiles android.Paths
	ctx.VisitAllModules(func(module android.Module) {
		if !ctx.ModuleHasProvider(module, DeclarationsProviderKey) {
		decl, ok := android.SingletonModuleProvider(ctx, module, DeclarationsProviderKey)
		if !ok {
			return
		}
		decl := ctx.ModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData)
		cacheFiles = append(cacheFiles, decl.IntermediateCacheOutputPath)
	})

Loading