Consolidate baseContext, BaseContext, and BaseModuleContext

blueprint.BaseModuleContext is the set of methods available to all
module-specific calls (GenerateBuildActions or mutators).  The
android package split the same functionality across baseContext (nee
androidBaseContext), BaseModuleContext, and BaseContext.
Consolidate all of them into android.BaseModuleContext.

Test: m checkbuild
Change-Id: I2d7f5c56fd4424032cb93edff6dc730ff33e4f1e
diff --git a/android/api_levels.go b/android/api_levels.go
index 51d4703..961685a 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -85,7 +85,7 @@
 // * Numeric API levels are simply converted.
 // * "minimum" and "current" are not currently handled since the former is
 //   NDK specific and the latter has inconsistent meaning.
-func ApiStrToNum(ctx BaseContext, apiLevel string) (int, error) {
+func ApiStrToNum(ctx BaseModuleContext, apiLevel string) (int, error) {
 	num, ok := getApiLevelsMap(ctx.Config())[apiLevel]
 	if ok {
 		return num, nil
diff --git a/android/hooks.go b/android/hooks.go
index 163220c..2d2f797 100644
--- a/android/hooks.go
+++ b/android/hooks.go
@@ -27,7 +27,7 @@
 // been applied.
 type LoadHookContext interface {
 	// TODO: a new context that includes Config() but not Target(), etc.?
-	BaseContext
+	BaseModuleContext
 	AppendProperties(...interface{})
 	PrependProperties(...interface{})
 	CreateModule(blueprint.ModuleFactory, ...interface{})
@@ -36,7 +36,7 @@
 // Arch hooks are run after the module has been split into architecture variants, and can be used
 // to add architecture-specific properties.
 type ArchHookContext interface {
-	BaseContext
+	BaseModuleContext
 	AppendProperties(...interface{})
 	PrependProperties(...interface{})
 }
diff --git a/android/module.go b/android/module.go
index c3d5f6a..9d73859 100644
--- a/android/module.go
+++ b/android/module.go
@@ -56,7 +56,30 @@
 
 type ModuleBuildParams BuildParams
 
-type baseContext interface {
+// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
+// a Config instead of an interface{}, plus some extra methods that return Android-specific information
+// about the current module.
+type BaseModuleContext interface {
+	ModuleName() string
+	ModuleDir() string
+	ModuleType() string
+	Config() Config
+
+	ContainsProperty(name string) bool
+	Errorf(pos scanner.Position, fmt string, args ...interface{})
+	ModuleErrorf(fmt string, args ...interface{})
+	PropertyErrorf(property, fmt string, args ...interface{})
+	Failed() bool
+
+	// GlobWithDeps returns a list of files that match the specified pattern but do not match any
+	// of the patterns in excludes.  It also adds efficient dependencies to rerun the primary
+	// builder whenever a file matching the pattern as added or removed, without rerunning if a
+	// file that does not match the pattern is added to a searched directory.
+	GlobWithDeps(pattern string, excludes []string) ([]string, error)
+
+	Fs() pathtools.FileSystem
+	AddNinjaFileDeps(deps ...string)
+
 	Target() Target
 	TargetPrimary() bool
 	MultiTargets() []Target
@@ -78,37 +101,12 @@
 	DeviceConfig() DeviceConfig
 }
 
+// Deprecated: use BaseModuleContext instead
 type BaseContext interface {
 	BaseModuleContext
-	baseContext
-}
-
-// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
-// a Config instead of an interface{}.
-type BaseModuleContext interface {
-	ModuleName() string
-	ModuleDir() string
-	ModuleType() string
-	Config() Config
-
-	ContainsProperty(name string) bool
-	Errorf(pos scanner.Position, fmt string, args ...interface{})
-	ModuleErrorf(fmt string, args ...interface{})
-	PropertyErrorf(property, fmt string, args ...interface{})
-	Failed() bool
-
-	// GlobWithDeps returns a list of files that match the specified pattern but do not match any
-	// of the patterns in excludes.  It also adds efficient dependencies to rerun the primary
-	// builder whenever a file matching the pattern as added or removed, without rerunning if a
-	// file that does not match the pattern is added to a searched directory.
-	GlobWithDeps(pattern string, excludes []string) ([]string, error)
-
-	Fs() pathtools.FileSystem
-	AddNinjaFileDeps(deps ...string)
 }
 
 type ModuleContext interface {
-	baseContext
 	BaseModuleContext
 
 	// Deprecated: use ModuleContext.Build instead.
@@ -826,25 +824,26 @@
 	}
 }
 
-func (m *ModuleBase) baseContextFactory(ctx blueprint.BaseModuleContext) baseContextImpl {
-	return baseContextImpl{
-		target:        m.commonProperties.CompileTarget,
-		targetPrimary: m.commonProperties.CompilePrimary,
-		multiTargets:  m.commonProperties.CompileMultiTargets,
-		kind:          determineModuleKind(m, ctx),
-		config:        ctx.Config().(Config),
+func (m *ModuleBase) baseModuleContextFactory(ctx blueprint.BaseModuleContext) baseModuleContext {
+	return baseModuleContext{
+		BaseModuleContext: ctx,
+		target:            m.commonProperties.CompileTarget,
+		targetPrimary:     m.commonProperties.CompilePrimary,
+		multiTargets:      m.commonProperties.CompileMultiTargets,
+		kind:              determineModuleKind(m, ctx),
+		config:            ctx.Config().(Config),
 	}
 }
 
 func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
 	ctx := &moduleContext{
-		module:          m.module,
-		ModuleContext:   blueprintCtx,
-		baseContextImpl: m.baseContextFactory(blueprintCtx),
-		installDeps:     m.computeInstallDeps(blueprintCtx),
-		installFiles:    m.installFiles,
-		missingDeps:     blueprintCtx.GetMissingDependencies(),
-		variables:       make(map[string]string),
+		module:            m.module,
+		ModuleContext:     blueprintCtx,
+		baseModuleContext: m.baseModuleContextFactory(blueprintCtx),
+		installDeps:       m.computeInstallDeps(blueprintCtx),
+		installFiles:      m.installFiles,
+		missingDeps:       blueprintCtx.GetMissingDependencies(),
+		variables:         make(map[string]string),
 	}
 
 	if ctx.config.captureBuild {
@@ -917,7 +916,8 @@
 	m.variables = ctx.variables
 }
 
-type baseContextImpl struct {
+type baseModuleContext struct {
+	blueprint.BaseModuleContext
 	target        Target
 	multiTargets  []Target
 	targetPrimary bool
@@ -928,7 +928,7 @@
 
 type moduleContext struct {
 	blueprint.ModuleContext
-	baseContextImpl
+	baseModuleContext
 	installDeps     Paths
 	installFiles    Paths
 	checkbuildFiles Paths
@@ -1210,82 +1210,82 @@
 	return m.ModuleContext.FinalModule().(Module)
 }
 
-func (b *baseContextImpl) Target() Target {
+func (b *baseModuleContext) Target() Target {
 	return b.target
 }
 
-func (b *baseContextImpl) TargetPrimary() bool {
+func (b *baseModuleContext) TargetPrimary() bool {
 	return b.targetPrimary
 }
 
-func (b *baseContextImpl) MultiTargets() []Target {
+func (b *baseModuleContext) MultiTargets() []Target {
 	return b.multiTargets
 }
 
-func (b *baseContextImpl) Arch() Arch {
+func (b *baseModuleContext) Arch() Arch {
 	return b.target.Arch
 }
 
-func (b *baseContextImpl) Os() OsType {
+func (b *baseModuleContext) Os() OsType {
 	return b.target.Os
 }
 
-func (b *baseContextImpl) Host() bool {
+func (b *baseModuleContext) Host() bool {
 	return b.target.Os.Class == Host || b.target.Os.Class == HostCross
 }
 
-func (b *baseContextImpl) Device() bool {
+func (b *baseModuleContext) Device() bool {
 	return b.target.Os.Class == Device
 }
 
-func (b *baseContextImpl) Darwin() bool {
+func (b *baseModuleContext) Darwin() bool {
 	return b.target.Os == Darwin
 }
 
-func (b *baseContextImpl) Fuchsia() bool {
+func (b *baseModuleContext) Fuchsia() bool {
 	return b.target.Os == Fuchsia
 }
 
-func (b *baseContextImpl) Windows() bool {
+func (b *baseModuleContext) Windows() bool {
 	return b.target.Os == Windows
 }
 
-func (b *baseContextImpl) Debug() bool {
+func (b *baseModuleContext) Debug() bool {
 	return b.debug
 }
 
-func (b *baseContextImpl) PrimaryArch() bool {
+func (b *baseModuleContext) PrimaryArch() bool {
 	if len(b.config.Targets[b.target.Os]) <= 1 {
 		return true
 	}
 	return b.target.Arch.ArchType == b.config.Targets[b.target.Os][0].Arch.ArchType
 }
 
-func (b *baseContextImpl) AConfig() Config {
+func (b *baseModuleContext) AConfig() Config {
 	return b.config
 }
 
-func (b *baseContextImpl) DeviceConfig() DeviceConfig {
+func (b *baseModuleContext) DeviceConfig() DeviceConfig {
 	return DeviceConfig{b.config.deviceConfig}
 }
 
-func (b *baseContextImpl) Platform() bool {
+func (b *baseModuleContext) Platform() bool {
 	return b.kind == platformModule
 }
 
-func (b *baseContextImpl) DeviceSpecific() bool {
+func (b *baseModuleContext) DeviceSpecific() bool {
 	return b.kind == deviceSpecificModule
 }
 
-func (b *baseContextImpl) SocSpecific() bool {
+func (b *baseModuleContext) SocSpecific() bool {
 	return b.kind == socSpecificModule
 }
 
-func (b *baseContextImpl) ProductSpecific() bool {
+func (b *baseModuleContext) ProductSpecific() bool {
 	return b.kind == productSpecificModule
 }
 
-func (b *baseContextImpl) ProductServicesSpecific() bool {
+func (b *baseModuleContext) ProductServicesSpecific() bool {
 	return b.kind == productServicesSpecificModule
 }
 
diff --git a/android/mutator.go b/android/mutator.go
index 5a92f70..cd0d152 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -114,7 +114,6 @@
 
 type TopDownMutatorContext interface {
 	BaseModuleContext
-	baseContext
 
 	OtherModuleExists(name string) bool
 	Rename(name string)
@@ -143,7 +142,7 @@
 
 type topDownMutatorContext struct {
 	blueprint.TopDownMutatorContext
-	baseContextImpl
+	baseModuleContext
 	walkPath []Module
 }
 
@@ -151,7 +150,6 @@
 
 type BottomUpMutatorContext interface {
 	BaseModuleContext
-	baseContext
 
 	OtherModuleExists(name string) bool
 	Rename(name string)
@@ -170,7 +168,7 @@
 
 type bottomUpMutatorContext struct {
 	blueprint.BottomUpMutatorContext
-	baseContextImpl
+	baseModuleContext
 }
 
 func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) MutatorHandle {
@@ -178,7 +176,7 @@
 		if a, ok := ctx.Module().(Module); ok {
 			actx := &bottomUpMutatorContext{
 				BottomUpMutatorContext: ctx,
-				baseContextImpl:        a.base().baseContextFactory(ctx),
+				baseModuleContext:      a.base().baseModuleContextFactory(ctx),
 			}
 			m(actx)
 		}
@@ -193,7 +191,7 @@
 		if a, ok := ctx.Module().(Module); ok {
 			actx := &topDownMutatorContext{
 				TopDownMutatorContext: ctx,
-				baseContextImpl:       a.base().baseContextFactory(ctx),
+				baseModuleContext:     a.base().baseModuleContextFactory(ctx),
 			}
 			m(actx)
 		}
diff --git a/android/paths.go b/android/paths.go
index d7d7792..52d22d5 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -41,9 +41,7 @@
 var _ PathContext = ModuleContext(nil)
 
 type ModuleInstallPathContext interface {
-	PathContext
-
-	baseContext
+	BaseModuleContext
 
 	InstallInData() bool
 	InstallInSanitizerDir() bool
diff --git a/android/paths_test.go b/android/paths_test.go
index dc42c76..78cfbbe 100644
--- a/android/paths_test.go
+++ b/android/paths_test.go
@@ -200,7 +200,7 @@
 }
 
 type moduleInstallPathContextImpl struct {
-	baseContextImpl
+	baseModuleContext
 
 	inData         bool
 	inSanitizerDir bool
@@ -212,7 +212,7 @@
 }
 
 func (m moduleInstallPathContextImpl) Config() Config {
-	return m.baseContextImpl.config
+	return m.baseModuleContext.config
 }
 
 func (moduleInstallPathContextImpl) AddNinjaFileDeps(deps ...string) {}
@@ -244,7 +244,7 @@
 		{
 			name: "host binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: hostTarget,
 				},
 			},
@@ -255,7 +255,7 @@
 		{
 			name: "system binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 				},
 			},
@@ -265,7 +265,7 @@
 		{
 			name: "vendor binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   socSpecificModule,
 				},
@@ -276,7 +276,7 @@
 		{
 			name: "odm binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   deviceSpecificModule,
 				},
@@ -287,7 +287,7 @@
 		{
 			name: "product binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   productSpecificModule,
 				},
@@ -298,7 +298,7 @@
 		{
 			name: "product_services binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   productServicesSpecificModule,
 				},
@@ -310,7 +310,7 @@
 		{
 			name: "system native test binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 				},
 				inData: true,
@@ -321,7 +321,7 @@
 		{
 			name: "vendor native test binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   socSpecificModule,
 				},
@@ -333,7 +333,7 @@
 		{
 			name: "odm native test binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   deviceSpecificModule,
 				},
@@ -345,7 +345,7 @@
 		{
 			name: "product native test binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   productSpecificModule,
 				},
@@ -358,7 +358,7 @@
 		{
 			name: "product_services native test binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   productServicesSpecificModule,
 				},
@@ -371,7 +371,7 @@
 		{
 			name: "sanitized system binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 				},
 				inSanitizerDir: true,
@@ -382,7 +382,7 @@
 		{
 			name: "sanitized vendor binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   socSpecificModule,
 				},
@@ -394,7 +394,7 @@
 		{
 			name: "sanitized odm binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   deviceSpecificModule,
 				},
@@ -406,7 +406,7 @@
 		{
 			name: "sanitized product binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   productSpecificModule,
 				},
@@ -419,7 +419,7 @@
 		{
 			name: "sanitized product_services binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   productServicesSpecificModule,
 				},
@@ -432,7 +432,7 @@
 		{
 			name: "sanitized system native test binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 				},
 				inData:         true,
@@ -444,7 +444,7 @@
 		{
 			name: "sanitized vendor native test binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   socSpecificModule,
 				},
@@ -457,7 +457,7 @@
 		{
 			name: "sanitized odm native test binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   deviceSpecificModule,
 				},
@@ -470,7 +470,7 @@
 		{
 			name: "sanitized product native test binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   productSpecificModule,
 				},
@@ -483,7 +483,7 @@
 		{
 			name: "sanitized product_services native test binary",
 			ctx: &moduleInstallPathContextImpl{
-				baseContextImpl: baseContextImpl{
+				baseModuleContext: baseModuleContext{
 					target: deviceTarget,
 					kind:   productServicesSpecificModule,
 				},
@@ -497,7 +497,7 @@
 
 	for _, tc := range testCases {
 		t.Run(tc.name, func(t *testing.T) {
-			tc.ctx.baseContextImpl.config = testConfig
+			tc.ctx.baseModuleContext.config = testConfig
 			output := PathForModuleInstall(tc.ctx, tc.in...)
 			if output.basePath.path != tc.out {
 				t.Errorf("unexpected path:\n got: %q\nwant: %q\n",
diff --git a/apex/apex.go b/apex/apex.go
index aed7d6f..41a21c9 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -552,7 +552,7 @@
 	}
 }
 
-func (a *apexBundle) getCertString(ctx android.BaseContext) string {
+func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
 	certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName())
 	if overridden {
 		return ":" + certificate
diff --git a/cc/cc.go b/cc/cc.go
index e61857d..559fe4b 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -278,7 +278,7 @@
 }
 
 type BaseModuleContext interface {
-	android.BaseContext
+	android.BaseModuleContext
 	ModuleContextIntf
 }
 
@@ -641,7 +641,7 @@
 }
 
 type baseModuleContext struct {
-	android.BaseContext
+	android.BaseModuleContext
 	moduleContextImpl
 }
 
@@ -1040,7 +1040,7 @@
 	}
 }
 
-func (c *Module) toolchain(ctx android.BaseContext) config.Toolchain {
+func (c *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain {
 	if c.cachedToolchain == nil {
 		c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch())
 	}
@@ -1161,7 +1161,7 @@
 
 func (c *Module) beginMutator(actx android.BottomUpMutatorContext) {
 	ctx := &baseModuleContext{
-		BaseContext: actx,
+		BaseModuleContext: actx,
 		moduleContextImpl: moduleContextImpl{
 			mod: c,
 		},
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index ff990b5..44f773c 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -121,7 +121,7 @@
 	}
 }
 
-func normalizeNdkApiLevel(ctx android.BaseContext, apiLevel string,
+func normalizeNdkApiLevel(ctx android.BaseModuleContext, apiLevel string,
 	arch android.Arch) (string, error) {
 
 	if apiLevel == "current" {
@@ -167,7 +167,7 @@
 	return strconv.Atoi(firstSupportedVersion)
 }
 
-func shouldUseVersionScript(ctx android.BaseContext, stub *stubDecorator) (bool, error) {
+func shouldUseVersionScript(ctx android.BaseModuleContext, stub *stubDecorator) (bool, error) {
 	// unversioned_until is normally empty, in which case we should use the version script.
 	if String(stub.properties.Unversioned_until) == "" {
 		return true, nil
diff --git a/java/app.go b/java/app.go
index 3c8f847..cf9354f 100644
--- a/java/app.go
+++ b/java/app.go
@@ -482,7 +482,7 @@
 	return jniLibs, certificates
 }
 
-func (a *AndroidApp) getCertString(ctx android.BaseContext) string {
+func (a *AndroidApp) getCertString(ctx android.BaseModuleContext) string {
 	certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName())
 	if overridden {
 		return ":" + certificate
diff --git a/java/java.go b/java/java.go
index 5544f57..fee262d 100644
--- a/java/java.go
+++ b/java/java.go
@@ -380,8 +380,8 @@
 }
 
 type SdkLibraryDependency interface {
-	SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths
-	SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths
+	SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths
+	SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths
 }
 
 type SrcDependency interface {
@@ -448,11 +448,11 @@
 	target android.Target
 }
 
-func (j *Module) shouldInstrument(ctx android.BaseContext) bool {
+func (j *Module) shouldInstrument(ctx android.BaseModuleContext) bool {
 	return j.properties.Instrument && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT")
 }
 
-func (j *Module) shouldInstrumentStatic(ctx android.BaseContext) bool {
+func (j *Module) shouldInstrumentStatic(ctx android.BaseModuleContext) bool {
 	return j.shouldInstrument(ctx) &&
 		(ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_STATIC") ||
 			ctx.Config().UnbundledBuild())
diff --git a/java/sdk.go b/java/sdk.go
index 506edfb..90b8fac 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -46,7 +46,7 @@
 	targetSdkVersion() string
 }
 
-func sdkVersionOrDefault(ctx android.BaseContext, v string) string {
+func sdkVersionOrDefault(ctx android.BaseModuleContext, v string) string {
 	switch v {
 	case "", "current", "system_current", "test_current", "core_current":
 		return ctx.Config().DefaultAppTargetSdk()
@@ -57,7 +57,7 @@
 
 // Returns a sdk version as a number.  For modules targeting an unreleased SDK (meaning it does not yet have a number)
 // it returns android.FutureApiLevel (10000).
-func sdkVersionToNumber(ctx android.BaseContext, v string) (int, error) {
+func sdkVersionToNumber(ctx android.BaseModuleContext, v string) (int, error) {
 	switch v {
 	case "", "current", "test_current", "system_current", "core_current":
 		return ctx.Config().DefaultAppTargetSdkInt(), nil
@@ -71,7 +71,7 @@
 	}
 }
 
-func sdkVersionToNumberAsString(ctx android.BaseContext, v string) (string, error) {
+func sdkVersionToNumberAsString(ctx android.BaseModuleContext, v string) (string, error) {
 	n, err := sdkVersionToNumber(ctx, v)
 	if err != nil {
 		return "", err
@@ -79,7 +79,7 @@
 	return strconv.Itoa(n), nil
 }
 
-func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep {
+func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep {
 	v := sdkContext.sdkVersion()
 	// For PDK builds, use the latest SDK version instead of "current"
 	if ctx.Config().IsPdkBuild() && (v == "" || v == "current") {
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 5b65c0c..e383533 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -591,7 +591,7 @@
 	mctx.CreateModule(android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory), &etcProps)
 }
 
-func (module *SdkLibrary) PrebuiltJars(ctx android.BaseContext, sdkVersion string) android.Paths {
+func (module *SdkLibrary) PrebuiltJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
 	var api, v string
 	if sdkVersion == "" {
 		api = "system"
@@ -615,7 +615,7 @@
 }
 
 // to satisfy SdkLibraryDependency interface
-func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths {
+func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
 	// This module is just a wrapper for the stubs.
 	if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
 		return module.PrebuiltJars(ctx, sdkVersion)
@@ -631,7 +631,7 @@
 }
 
 // to satisfy SdkLibraryDependency interface
-func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths {
+func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
 	// This module is just a wrapper for the stubs.
 	if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
 		return module.PrebuiltJars(ctx, sdkVersion)
@@ -840,13 +840,13 @@
 }
 
 // to satisfy SdkLibraryDependency interface
-func (module *sdkLibraryImport) SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths {
+func (module *sdkLibraryImport) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
 	// This module is just a wrapper for the prebuilt stubs.
 	return module.stubsPath
 }
 
 // to satisfy SdkLibraryDependency interface
-func (module *sdkLibraryImport) SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths {
+func (module *sdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
 	// This module is just a wrapper for the stubs.
 	return module.stubsPath
 }