Add GetEmbeddedPrebuilt and IsModulePrebuilt
Dedups the many repetitions of the code to obtain a *Prebuilt from a
module.
Bug: 177892522
Test: m nothing
Change-Id: I1ededbe9ee79e89ea6dd8882dfee4be0bf0b51b7
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 8a656ed..7397919 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -404,14 +404,14 @@
if parent == ctx.Module() && ctx.OtherModuleDependencyTag(child) == Dex2oatDepTag {
// Found the source module, or prebuilt module that has replaced the source.
dex2oatModule = child
- if p, ok := child.(android.PrebuiltInterface); ok && p.Prebuilt() != nil {
+ if android.IsModulePrebuilt(child) {
return false // If it's the prebuilt we're done.
} else {
return true // Recurse to check if the source has a prebuilt dependency.
}
}
if parent == dex2oatModule && ctx.OtherModuleDependencyTag(child) == android.PrebuiltDepTag {
- if p, ok := child.(android.PrebuiltInterface); ok && p.Prebuilt() != nil && p.Prebuilt().UsePrebuilt() {
+ if p := android.GetEmbeddedPrebuilt(child); p != nil && p.UsePrebuilt() {
dex2oatModule = child // Found a prebuilt that should be used.
}
}