Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 1 | // Copyright (C) 2019 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 | |
| 15 | package selinux |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
| 19 | "io" |
Inseob Kim | 2dac267 | 2021-12-29 17:54:57 +0900 | [diff] [blame] | 20 | "os" |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 21 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 22 | "github.com/google/blueprint" |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 23 | "github.com/google/blueprint/proptools" |
| 24 | |
| 25 | "android/soong/android" |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 26 | "android/soong/sysprop" |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 27 | ) |
| 28 | |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 29 | type selinuxContextsProperties struct { |
| 30 | // Filenames under sepolicy directories, which will be used to generate contexts file. |
| 31 | Srcs []string `android:"path"` |
| 32 | |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 33 | // Output file name. Defaults to module name |
| 34 | Stem *string |
| 35 | |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 36 | Product_variables struct { |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 37 | Address_sanitize struct { |
Inseob Kim | 6d3d5a6 | 2021-12-21 20:55:32 +0900 | [diff] [blame] | 38 | Srcs []string `android:"path"` |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 39 | } |
| 40 | } |
| 41 | |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 42 | // Whether the comments in generated contexts file will be removed or not. |
| 43 | Remove_comment *bool |
| 44 | |
| 45 | // Whether the result context file is sorted with fc_sort or not. |
| 46 | Fc_sort *bool |
| 47 | |
| 48 | // Make this module available when building for recovery |
| 49 | Recovery_available *bool |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 50 | } |
| 51 | |
Inseob Kim | 2dac267 | 2021-12-29 17:54:57 +0900 | [diff] [blame] | 52 | type seappProperties struct { |
| 53 | // Files containing neverallow rules. |
| 54 | Neverallow_files []string `android:"path"` |
| 55 | |
| 56 | // Precompiled sepolicy binary file which will be fed to checkseapp. |
| 57 | Sepolicy *string `android:"path"` |
| 58 | } |
| 59 | |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 60 | type selinuxContextsModule struct { |
| 61 | android.ModuleBase |
| 62 | |
Jooyung Han | 804e234 | 2023-06-20 15:38:50 +0900 | [diff] [blame] | 63 | properties selinuxContextsProperties |
| 64 | seappProperties seappProperties |
| 65 | build func(ctx android.ModuleContext, inputs android.Paths) android.Path |
| 66 | deps func(ctx android.BottomUpMutatorContext) |
| 67 | outputPath android.Path |
| 68 | installPath android.InstallPath |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | var ( |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 72 | reuseContextsDepTag = dependencyTag{name: "reuseContexts"} |
| 73 | syspropLibraryDepTag = dependencyTag{name: "sysprop_library"} |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 74 | ) |
| 75 | |
| 76 | func init() { |
| 77 | pctx.HostBinToolVariable("fc_sort", "fc_sort") |
| 78 | |
| 79 | android.RegisterModuleType("file_contexts", fileFactory) |
| 80 | android.RegisterModuleType("hwservice_contexts", hwServiceFactory) |
| 81 | android.RegisterModuleType("property_contexts", propertyFactory) |
| 82 | android.RegisterModuleType("service_contexts", serviceFactory) |
Janis Danisevskis | c40681f | 2020-07-25 13:02:29 -0700 | [diff] [blame] | 83 | android.RegisterModuleType("keystore2_key_contexts", keystoreKeyFactory) |
Inseob Kim | 2dac267 | 2021-12-29 17:54:57 +0900 | [diff] [blame] | 84 | android.RegisterModuleType("seapp_contexts", seappFactory) |
Inseob Kim | c7596c4 | 2022-02-25 11:45:41 +0900 | [diff] [blame] | 85 | android.RegisterModuleType("vndservice_contexts", vndServiceFactory) |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 86 | |
| 87 | android.RegisterModuleType("file_contexts_test", fileContextsTestFactory) |
| 88 | android.RegisterModuleType("property_contexts_test", propertyContextsTestFactory) |
| 89 | android.RegisterModuleType("hwservice_contexts_test", hwserviceContextsTestFactory) |
| 90 | android.RegisterModuleType("service_contexts_test", serviceContextsTestFactory) |
Inseob Kim | c7596c4 | 2022-02-25 11:45:41 +0900 | [diff] [blame] | 91 | android.RegisterModuleType("vndservice_contexts_test", vndServiceContextsTestFactory) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 92 | } |
| 93 | |
Colin Cross | 040f151 | 2019-10-02 10:36:09 -0700 | [diff] [blame] | 94 | func (m *selinuxContextsModule) InstallInRoot() bool { |
Inseob Kim | fa6fe47 | 2021-01-12 13:40:27 +0900 | [diff] [blame] | 95 | return m.InRecovery() |
| 96 | } |
| 97 | |
| 98 | func (m *selinuxContextsModule) InstallInRecovery() bool { |
| 99 | // ModuleBase.InRecovery() checks the image variant |
| 100 | return m.InRecovery() |
| 101 | } |
| 102 | |
| 103 | func (m *selinuxContextsModule) onlyInRecovery() bool { |
| 104 | // ModuleBase.InstallInRecovery() checks commonProperties.Recovery property |
| 105 | return m.ModuleBase.InstallInRecovery() |
Colin Cross | 040f151 | 2019-10-02 10:36:09 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 108 | func (m *selinuxContextsModule) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 109 | if m.deps != nil { |
| 110 | m.deps(ctx) |
| 111 | } |
Inseob Kim | fa6fe47 | 2021-01-12 13:40:27 +0900 | [diff] [blame] | 112 | |
| 113 | if m.InRecovery() && !m.onlyInRecovery() { |
| 114 | ctx.AddFarVariationDependencies([]blueprint.Variation{ |
| 115 | {Mutator: "image", Variation: android.CoreVariation}, |
| 116 | }, reuseContextsDepTag, ctx.ModuleName()) |
| 117 | } |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | func (m *selinuxContextsModule) propertyContextsDeps(ctx android.BottomUpMutatorContext) { |
| 121 | for _, lib := range sysprop.SyspropLibraries(ctx.Config()) { |
| 122 | ctx.AddFarVariationDependencies([]blueprint.Variation{}, syspropLibraryDepTag, lib) |
| 123 | } |
| 124 | } |
| 125 | |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 126 | func (m *selinuxContextsModule) stem() string { |
| 127 | return proptools.StringDefault(m.properties.Stem, m.Name()) |
| 128 | } |
| 129 | |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 130 | func (m *selinuxContextsModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Inseob Kim | fa6fe47 | 2021-01-12 13:40:27 +0900 | [diff] [blame] | 131 | if m.InRecovery() { |
Colin Cross | 040f151 | 2019-10-02 10:36:09 -0700 | [diff] [blame] | 132 | // Installing context files at the root of the recovery partition |
| 133 | m.installPath = android.PathForModuleInstall(ctx) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 134 | } else { |
| 135 | m.installPath = android.PathForModuleInstall(ctx, "etc", "selinux") |
| 136 | } |
| 137 | |
Inseob Kim | fa6fe47 | 2021-01-12 13:40:27 +0900 | [diff] [blame] | 138 | if m.InRecovery() && !m.onlyInRecovery() { |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 139 | dep := ctx.GetDirectDepWithTag(m.Name(), reuseContextsDepTag) |
| 140 | |
| 141 | if reuseDeps, ok := dep.(*selinuxContextsModule); ok { |
| 142 | m.outputPath = reuseDeps.outputPath |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 143 | ctx.InstallFile(m.installPath, m.stem(), m.outputPath) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 144 | return |
| 145 | } |
| 146 | } |
| 147 | |
Inseob Kim | 6d3d5a6 | 2021-12-21 20:55:32 +0900 | [diff] [blame] | 148 | m.outputPath = m.build(ctx, android.PathsForModuleSrc(ctx, m.properties.Srcs)) |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 149 | ctx.InstallFile(m.installPath, m.stem(), m.outputPath) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | func newModule() *selinuxContextsModule { |
| 153 | m := &selinuxContextsModule{} |
| 154 | m.AddProperties( |
| 155 | &m.properties, |
Inseob Kim | 2dac267 | 2021-12-29 17:54:57 +0900 | [diff] [blame] | 156 | &m.seappProperties, |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 157 | ) |
| 158 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 159 | android.AddLoadHook(m, func(ctx android.LoadHookContext) { |
| 160 | m.selinuxContextsHook(ctx) |
| 161 | }) |
| 162 | return m |
| 163 | } |
| 164 | |
| 165 | func (m *selinuxContextsModule) selinuxContextsHook(ctx android.LoadHookContext) { |
| 166 | // TODO: clean this up to use build/soong/android/variable.go after b/79249983 |
| 167 | var srcs []string |
| 168 | |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 169 | for _, sanitize := range ctx.Config().SanitizeDevice() { |
| 170 | if sanitize == "address" { |
| 171 | srcs = append(srcs, m.properties.Product_variables.Address_sanitize.Srcs...) |
| 172 | break |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | m.properties.Srcs = append(m.properties.Srcs, srcs...) |
| 177 | } |
| 178 | |
| 179 | func (m *selinuxContextsModule) AndroidMk() android.AndroidMkData { |
Colin Cross | f82aed0 | 2021-11-04 17:25:55 -0700 | [diff] [blame] | 180 | nameSuffix := "" |
| 181 | if m.InRecovery() && !m.onlyInRecovery() { |
| 182 | nameSuffix = ".recovery" |
| 183 | } |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 184 | return android.AndroidMkData{ |
Colin Cross | f82aed0 | 2021-11-04 17:25:55 -0700 | [diff] [blame] | 185 | Class: "ETC", |
| 186 | OutputFile: android.OptionalPathForPath(m.outputPath), |
| 187 | SubName: nameSuffix, |
| 188 | Extra: []android.AndroidMkExtraFunc{ |
| 189 | func(w io.Writer, outputFile android.Path) { |
Colin Cross | 6c7f937 | 2022-01-11 19:35:43 -0800 | [diff] [blame] | 190 | fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", m.installPath.String()) |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 191 | fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", m.stem()) |
Colin Cross | f82aed0 | 2021-11-04 17:25:55 -0700 | [diff] [blame] | 192 | }, |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 193 | }, |
| 194 | } |
| 195 | } |
| 196 | |
Inseob Kim | fa6fe47 | 2021-01-12 13:40:27 +0900 | [diff] [blame] | 197 | func (m *selinuxContextsModule) ImageMutatorBegin(ctx android.BaseModuleContext) { |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 198 | if proptools.Bool(m.properties.Recovery_available) && m.ModuleBase.InstallInRecovery() { |
Inseob Kim | fa6fe47 | 2021-01-12 13:40:27 +0900 | [diff] [blame] | 199 | ctx.PropertyErrorf("recovery_available", |
| 200 | "doesn't make sense at the same time as `recovery: true`") |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 201 | } |
| 202 | } |
| 203 | |
Inseob Kim | fa6fe47 | 2021-01-12 13:40:27 +0900 | [diff] [blame] | 204 | func (m *selinuxContextsModule) CoreVariantNeeded(ctx android.BaseModuleContext) bool { |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 205 | return !m.ModuleBase.InstallInRecovery() |
Inseob Kim | fa6fe47 | 2021-01-12 13:40:27 +0900 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | func (m *selinuxContextsModule) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 209 | return false |
| 210 | } |
| 211 | |
| 212 | func (m *selinuxContextsModule) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 213 | return false |
| 214 | } |
| 215 | |
Inseob Kim | 6cc75f4 | 2021-04-29 13:53:20 +0000 | [diff] [blame] | 216 | func (m *selinuxContextsModule) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 217 | return false |
| 218 | } |
| 219 | |
Inseob Kim | fa6fe47 | 2021-01-12 13:40:27 +0900 | [diff] [blame] | 220 | func (m *selinuxContextsModule) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 221 | return m.ModuleBase.InstallInRecovery() || proptools.Bool(m.properties.Recovery_available) |
Inseob Kim | fa6fe47 | 2021-01-12 13:40:27 +0900 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | func (m *selinuxContextsModule) ExtraImageVariations(ctx android.BaseModuleContext) []string { |
| 225 | return nil |
| 226 | } |
| 227 | |
| 228 | func (m *selinuxContextsModule) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) { |
| 229 | } |
| 230 | |
| 231 | var _ android.ImageInterface = (*selinuxContextsModule)(nil) |
| 232 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 233 | func (m *selinuxContextsModule) buildGeneralContexts(ctx android.ModuleContext, inputs android.Paths) android.Path { |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 234 | builtContext := pathForModuleOut(ctx, ctx.ModuleName()+"_m4out") |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 235 | |
Colin Cross | 242c8bc | 2020-11-16 17:58:17 -0800 | [diff] [blame] | 236 | rule := android.NewRuleBuilder(pctx, ctx) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 237 | |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 238 | newlineFile := pathForModuleOut(ctx, "newline") |
Inseob Kim | 35e9d41 | 2023-01-04 15:27:32 +0900 | [diff] [blame] | 239 | |
| 240 | rule.Command().Text("echo").FlagWithOutput("> ", newlineFile) |
| 241 | rule.Temporary(newlineFile) |
| 242 | |
| 243 | var inputsWithNewline android.Paths |
| 244 | for _, input := range inputs { |
| 245 | inputsWithNewline = append(inputsWithNewline, input, newlineFile) |
| 246 | } |
| 247 | |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 248 | rule.Command(). |
Dan Willemsen | 3c3e59b | 2019-06-19 10:52:50 -0700 | [diff] [blame] | 249 | Tool(ctx.Config().PrebuiltBuildTool(ctx, "m4")). |
| 250 | Text("--fatal-warnings -s"). |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 251 | FlagForEachArg("-D", ctx.DeviceConfig().SepolicyM4Defs()). |
Inseob Kim | 35e9d41 | 2023-01-04 15:27:32 +0900 | [diff] [blame] | 252 | Inputs(inputsWithNewline). |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 253 | FlagWithOutput("> ", builtContext) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 254 | |
| 255 | if proptools.Bool(m.properties.Remove_comment) { |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 256 | rule.Temporary(builtContext) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 257 | |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 258 | remove_comment_output := pathForModuleOut(ctx, ctx.ModuleName()+"_remove_comment") |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 259 | |
| 260 | rule.Command(). |
| 261 | Text("sed -e 's/#.*$//' -e '/^$/d'"). |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 262 | Input(builtContext). |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 263 | FlagWithOutput("> ", remove_comment_output) |
| 264 | |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 265 | builtContext = remove_comment_output |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | if proptools.Bool(m.properties.Fc_sort) { |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 269 | rule.Temporary(builtContext) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 270 | |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 271 | sorted_output := pathForModuleOut(ctx, ctx.ModuleName()+"_sorted") |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 272 | |
| 273 | rule.Command(). |
| 274 | Tool(ctx.Config().HostToolPath(ctx, "fc_sort")). |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 275 | FlagWithInput("-i ", builtContext). |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 276 | FlagWithOutput("-o ", sorted_output) |
| 277 | |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 278 | builtContext = sorted_output |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 279 | } |
| 280 | |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 281 | ret := pathForModuleOut(ctx, m.stem()) |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 282 | rule.Temporary(builtContext) |
| 283 | rule.Command().Text("cp").Input(builtContext).Output(ret) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 284 | |
| 285 | rule.DeleteTemporaryFiles() |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 286 | rule.Build("selinux_contexts", "building contexts: "+m.Name()) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 287 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 288 | return ret |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 289 | } |
| 290 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 291 | func (m *selinuxContextsModule) buildFileContexts(ctx android.ModuleContext, inputs android.Paths) android.Path { |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 292 | if m.properties.Fc_sort == nil { |
| 293 | m.properties.Fc_sort = proptools.BoolPtr(true) |
| 294 | } |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 295 | return m.buildGeneralContexts(ctx, inputs) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | func fileFactory() android.Module { |
| 299 | m := newModule() |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 300 | m.build = m.buildFileContexts |
| 301 | return m |
| 302 | } |
| 303 | |
Thiébaud Weksteen | 74482f5 | 2023-04-26 13:46:59 +1000 | [diff] [blame] | 304 | func (m *selinuxContextsModule) buildServiceContexts(ctx android.ModuleContext, inputs android.Paths) android.Path { |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 305 | if m.properties.Remove_comment == nil { |
| 306 | m.properties.Remove_comment = proptools.BoolPtr(true) |
| 307 | } |
| 308 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 309 | return m.buildGeneralContexts(ctx, inputs) |
| 310 | } |
| 311 | |
Inseob Kim | 2bcc045 | 2020-12-21 13:16:44 +0900 | [diff] [blame] | 312 | func (m *selinuxContextsModule) checkVendorPropertyNamespace(ctx android.ModuleContext, inputs android.Paths) android.Paths { |
| 313 | shippingApiLevel := ctx.DeviceConfig().ShippingApiLevel() |
| 314 | ApiLevelR := android.ApiLevelOrPanic(ctx, "R") |
| 315 | |
| 316 | rule := android.NewRuleBuilder(pctx, ctx) |
| 317 | |
| 318 | // This list is from vts_treble_sys_prop_test. |
| 319 | allowedPropertyPrefixes := []string{ |
| 320 | "ctl.odm.", |
| 321 | "ctl.vendor.", |
| 322 | "ctl.start$odm.", |
| 323 | "ctl.start$vendor.", |
| 324 | "ctl.stop$odm.", |
| 325 | "ctl.stop$vendor.", |
| 326 | "init.svc.odm.", |
| 327 | "init.svc.vendor.", |
| 328 | "ro.boot.", |
| 329 | "ro.hardware.", |
| 330 | "ro.odm.", |
| 331 | "ro.vendor.", |
| 332 | "odm.", |
| 333 | "persist.odm.", |
| 334 | "persist.vendor.", |
| 335 | "vendor.", |
| 336 | } |
| 337 | |
| 338 | // persist.camera is also allowed for devices launching with R or eariler |
| 339 | if shippingApiLevel.LessThanOrEqualTo(ApiLevelR) { |
| 340 | allowedPropertyPrefixes = append(allowedPropertyPrefixes, "persist.camera.") |
| 341 | } |
| 342 | |
| 343 | var allowedContextPrefixes []string |
| 344 | |
| 345 | if shippingApiLevel.GreaterThanOrEqualTo(ApiLevelR) { |
| 346 | // This list is from vts_treble_sys_prop_test. |
| 347 | allowedContextPrefixes = []string{ |
| 348 | "vendor_", |
| 349 | "odm_", |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | var ret android.Paths |
| 354 | for _, input := range inputs { |
| 355 | cmd := rule.Command(). |
| 356 | BuiltTool("check_prop_prefix"). |
| 357 | FlagWithInput("--property-contexts ", input). |
| 358 | FlagForEachArg("--allowed-property-prefix ", proptools.ShellEscapeList(allowedPropertyPrefixes)). // contains shell special character '$' |
| 359 | FlagForEachArg("--allowed-context-prefix ", allowedContextPrefixes) |
| 360 | |
| 361 | if !ctx.DeviceConfig().BuildBrokenVendorPropertyNamespace() { |
| 362 | cmd.Flag("--strict") |
| 363 | } |
| 364 | |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 365 | out := pathForModuleOut(ctx, "namespace_checked").Join(ctx, input.String()) |
Inseob Kim | 2bcc045 | 2020-12-21 13:16:44 +0900 | [diff] [blame] | 366 | rule.Command().Text("cp -f").Input(input).Output(out) |
| 367 | ret = append(ret, out) |
| 368 | } |
| 369 | rule.Build("check_namespace", "checking namespace of "+ctx.ModuleName()) |
| 370 | return ret |
| 371 | } |
| 372 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 373 | func (m *selinuxContextsModule) buildPropertyContexts(ctx android.ModuleContext, inputs android.Paths) android.Path { |
Inseob Kim | 2bcc045 | 2020-12-21 13:16:44 +0900 | [diff] [blame] | 374 | // vendor/odm properties are enforced for devices launching with Android Q or later. So, if |
| 375 | // vendor/odm, make sure that only vendor/odm properties exist. |
| 376 | shippingApiLevel := ctx.DeviceConfig().ShippingApiLevel() |
| 377 | ApiLevelQ := android.ApiLevelOrPanic(ctx, "Q") |
| 378 | if (ctx.SocSpecific() || ctx.DeviceSpecific()) && shippingApiLevel.GreaterThanOrEqualTo(ApiLevelQ) { |
| 379 | inputs = m.checkVendorPropertyNamespace(ctx, inputs) |
| 380 | } |
| 381 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 382 | builtCtxFile := m.buildGeneralContexts(ctx, inputs) |
| 383 | |
| 384 | var apiFiles android.Paths |
| 385 | ctx.VisitDirectDepsWithTag(syspropLibraryDepTag, func(c android.Module) { |
Inseob Kim | 3a3539a | 2021-01-15 18:10:29 +0900 | [diff] [blame] | 386 | i, ok := c.(interface{ CurrentSyspropApiFile() android.OptionalPath }) |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 387 | if !ok { |
| 388 | panic(fmt.Errorf("unknown dependency %q for %q", ctx.OtherModuleName(c), ctx.ModuleName())) |
| 389 | } |
Inseob Kim | 3a3539a | 2021-01-15 18:10:29 +0900 | [diff] [blame] | 390 | if api := i.CurrentSyspropApiFile(); api.Valid() { |
| 391 | apiFiles = append(apiFiles, api.Path()) |
| 392 | } |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 393 | }) |
| 394 | |
| 395 | // check compatibility with sysprop_library |
| 396 | if len(apiFiles) > 0 { |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 397 | out := pathForModuleOut(ctx, ctx.ModuleName()+"_api_checked") |
Colin Cross | 242c8bc | 2020-11-16 17:58:17 -0800 | [diff] [blame] | 398 | rule := android.NewRuleBuilder(pctx, ctx) |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 399 | |
| 400 | msg := `\n******************************\n` + |
| 401 | `API of sysprop_library doesn't match with property_contexts\n` + |
| 402 | `Please fix the breakage and rebuild.\n` + |
| 403 | `******************************\n` |
| 404 | |
| 405 | rule.Command(). |
| 406 | Text("( "). |
Colin Cross | 242c8bc | 2020-11-16 17:58:17 -0800 | [diff] [blame] | 407 | BuiltTool("sysprop_type_checker"). |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 408 | FlagForEachInput("--api ", apiFiles). |
| 409 | FlagWithInput("--context ", builtCtxFile). |
| 410 | Text(" || ( echo").Flag("-e"). |
| 411 | Flag(`"` + msg + `"`). |
| 412 | Text("; exit 38) )") |
| 413 | |
| 414 | rule.Command().Text("cp -f").Input(builtCtxFile).Output(out) |
Colin Cross | 242c8bc | 2020-11-16 17:58:17 -0800 | [diff] [blame] | 415 | rule.Build("property_contexts_check_api", "checking API: "+m.Name()) |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 416 | builtCtxFile = out |
| 417 | } |
| 418 | |
| 419 | return builtCtxFile |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 420 | } |
| 421 | |
Inseob Kim | 06518b1 | 2023-08-25 21:20:08 +0900 | [diff] [blame] | 422 | func (m *selinuxContextsModule) shouldCheckCoredomain(ctx android.ModuleContext) bool { |
| 423 | if !ctx.SocSpecific() && !ctx.DeviceSpecific() { |
| 424 | return false |
| 425 | } |
| 426 | |
| 427 | return ctx.DeviceConfig().CheckVendorSeappViolations() |
| 428 | } |
| 429 | |
Inseob Kim | 2dac267 | 2021-12-29 17:54:57 +0900 | [diff] [blame] | 430 | func (m *selinuxContextsModule) buildSeappContexts(ctx android.ModuleContext, inputs android.Paths) android.Path { |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 431 | neverallowFile := pathForModuleOut(ctx, "neverallow") |
| 432 | ret := pathForModuleOut(ctx, m.stem()) |
Inseob Kim | 2dac267 | 2021-12-29 17:54:57 +0900 | [diff] [blame] | 433 | |
| 434 | rule := android.NewRuleBuilder(pctx, ctx) |
| 435 | rule.Command().Text("(grep"). |
| 436 | Flag("-ihe"). |
| 437 | Text("'^neverallow'"). |
| 438 | Inputs(android.PathsForModuleSrc(ctx, m.seappProperties.Neverallow_files)). |
| 439 | Text(os.DevNull). // to make grep happy even when Neverallow_files is empty |
| 440 | Text(">"). |
| 441 | Output(neverallowFile). |
| 442 | Text("|| true)") // to make ninja happy even when result is empty |
| 443 | |
| 444 | rule.Temporary(neverallowFile) |
Inseob Kim | d7d3609 | 2023-06-26 20:48:48 +0900 | [diff] [blame] | 445 | checkCmd := rule.Command().BuiltTool("checkseapp"). |
Inseob Kim | 2dac267 | 2021-12-29 17:54:57 +0900 | [diff] [blame] | 446 | FlagWithInput("-p ", android.PathForModuleSrc(ctx, proptools.String(m.seappProperties.Sepolicy))). |
| 447 | FlagWithOutput("-o ", ret). |
| 448 | Inputs(inputs). |
| 449 | Input(neverallowFile) |
| 450 | |
Inseob Kim | 06518b1 | 2023-08-25 21:20:08 +0900 | [diff] [blame] | 451 | if m.shouldCheckCoredomain(ctx) { |
| 452 | checkCmd.Flag("-c") // check coredomain for vendor contexts |
Inseob Kim | d7d3609 | 2023-06-26 20:48:48 +0900 | [diff] [blame] | 453 | } |
| 454 | |
Inseob Kim | 2dac267 | 2021-12-29 17:54:57 +0900 | [diff] [blame] | 455 | rule.Build("seapp_contexts", "Building seapp_contexts: "+m.Name()) |
| 456 | return ret |
| 457 | } |
| 458 | |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 459 | func hwServiceFactory() android.Module { |
| 460 | m := newModule() |
Thiébaud Weksteen | 74482f5 | 2023-04-26 13:46:59 +1000 | [diff] [blame] | 461 | m.build = m.buildServiceContexts |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 462 | return m |
| 463 | } |
| 464 | |
| 465 | func propertyFactory() android.Module { |
| 466 | m := newModule() |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 467 | m.build = m.buildPropertyContexts |
| 468 | m.deps = m.propertyContextsDeps |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 469 | return m |
| 470 | } |
| 471 | |
| 472 | func serviceFactory() android.Module { |
| 473 | m := newModule() |
Thiébaud Weksteen | 74482f5 | 2023-04-26 13:46:59 +1000 | [diff] [blame] | 474 | m.build = m.buildServiceContexts |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 475 | return m |
| 476 | } |
Janis Danisevskis | c40681f | 2020-07-25 13:02:29 -0700 | [diff] [blame] | 477 | |
| 478 | func keystoreKeyFactory() android.Module { |
| 479 | m := newModule() |
| 480 | m.build = m.buildGeneralContexts |
| 481 | return m |
| 482 | } |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 483 | |
Inseob Kim | 2dac267 | 2021-12-29 17:54:57 +0900 | [diff] [blame] | 484 | func seappFactory() android.Module { |
| 485 | m := newModule() |
| 486 | m.build = m.buildSeappContexts |
| 487 | return m |
| 488 | } |
| 489 | |
Inseob Kim | c7596c4 | 2022-02-25 11:45:41 +0900 | [diff] [blame] | 490 | func vndServiceFactory() android.Module { |
| 491 | m := newModule() |
| 492 | m.build = m.buildGeneralContexts |
| 493 | android.AddLoadHook(m, func(ctx android.LoadHookContext) { |
| 494 | if !ctx.SocSpecific() { |
| 495 | ctx.ModuleErrorf(m.Name(), "must set vendor: true") |
| 496 | return |
| 497 | } |
| 498 | }) |
| 499 | return m |
| 500 | } |
| 501 | |
Yuntao Xu | 42e732c | 2021-11-18 22:33:02 +0000 | [diff] [blame] | 502 | var _ android.OutputFileProducer = (*selinuxContextsModule)(nil) |
| 503 | |
| 504 | // Implements android.OutputFileProducer |
| 505 | func (m *selinuxContextsModule) OutputFiles(tag string) (android.Paths, error) { |
| 506 | if tag == "" { |
| 507 | return []android.Path{m.outputPath}, nil |
| 508 | } |
| 509 | return nil, fmt.Errorf("unsupported module reference tag %q", tag) |
| 510 | } |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 511 | |
| 512 | type contextsTestProperties struct { |
| 513 | // Contexts files to be tested. |
| 514 | Srcs []string `android:"path"` |
| 515 | |
| 516 | // Precompiled sepolicy binary to be tesed together. |
| 517 | Sepolicy *string `android:"path"` |
| 518 | } |
| 519 | |
| 520 | type contextsTestModule struct { |
| 521 | android.ModuleBase |
| 522 | |
Thiébaud Weksteen | a69e14f | 2023-10-20 13:31:19 +1100 | [diff] [blame^] | 523 | // The type of context. |
| 524 | context contextType |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 525 | |
| 526 | properties contextsTestProperties |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 527 | testTimestamp android.OutputPath |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 528 | } |
| 529 | |
Thiébaud Weksteen | a69e14f | 2023-10-20 13:31:19 +1100 | [diff] [blame^] | 530 | type contextType int |
| 531 | |
| 532 | const ( |
| 533 | FileContext contextType = iota |
| 534 | PropertyContext |
| 535 | ServiceContext |
| 536 | HwServiceContext |
| 537 | VndServiceContext |
| 538 | ) |
| 539 | |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 540 | // checkfc parses a context file and checks for syntax errors. |
| 541 | // If -s is specified, the service backend is used to verify binder services. |
| 542 | // If -l is specified, the service backend is used to verify hwbinder services. |
| 543 | // Otherwise, context_file is assumed to be a file_contexts file |
| 544 | // If -e is specified, then the context_file is allowed to be empty. |
| 545 | |
| 546 | // file_contexts_test tests given file_contexts files with checkfc. |
| 547 | func fileContextsTestFactory() android.Module { |
Thiébaud Weksteen | a69e14f | 2023-10-20 13:31:19 +1100 | [diff] [blame^] | 548 | m := &contextsTestModule{context: FileContext} |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 549 | m.AddProperties(&m.properties) |
| 550 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 551 | return m |
| 552 | } |
| 553 | |
| 554 | // property_contexts_test tests given property_contexts files with property_info_checker. |
| 555 | func propertyContextsTestFactory() android.Module { |
Thiébaud Weksteen | a69e14f | 2023-10-20 13:31:19 +1100 | [diff] [blame^] | 556 | m := &contextsTestModule{context: PropertyContext} |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 557 | m.AddProperties(&m.properties) |
| 558 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 559 | return m |
| 560 | } |
| 561 | |
| 562 | // hwservice_contexts_test tests given hwservice_contexts files with checkfc. |
| 563 | func hwserviceContextsTestFactory() android.Module { |
Thiébaud Weksteen | a69e14f | 2023-10-20 13:31:19 +1100 | [diff] [blame^] | 564 | m := &contextsTestModule{context: HwServiceContext} |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 565 | m.AddProperties(&m.properties) |
| 566 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 567 | return m |
| 568 | } |
| 569 | |
| 570 | // service_contexts_test tests given service_contexts files with checkfc. |
| 571 | func serviceContextsTestFactory() android.Module { |
| 572 | // checkfc -s: service_contexts test |
Thiébaud Weksteen | a69e14f | 2023-10-20 13:31:19 +1100 | [diff] [blame^] | 573 | m := &contextsTestModule{context: ServiceContext} |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 574 | m.AddProperties(&m.properties) |
| 575 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 576 | return m |
| 577 | } |
| 578 | |
Inseob Kim | c7596c4 | 2022-02-25 11:45:41 +0900 | [diff] [blame] | 579 | // vndservice_contexts_test tests given vndservice_contexts files with checkfc. |
| 580 | func vndServiceContextsTestFactory() android.Module { |
Thiébaud Weksteen | a69e14f | 2023-10-20 13:31:19 +1100 | [diff] [blame^] | 581 | m := &contextsTestModule{context: VndServiceContext} |
Inseob Kim | c7596c4 | 2022-02-25 11:45:41 +0900 | [diff] [blame] | 582 | m.AddProperties(&m.properties) |
| 583 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 584 | return m |
| 585 | } |
| 586 | |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 587 | func (m *contextsTestModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Thiébaud Weksteen | a69e14f | 2023-10-20 13:31:19 +1100 | [diff] [blame^] | 588 | tool := "checkfc" |
| 589 | if m.context == PropertyContext { |
| 590 | tool = "property_info_checker" |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 591 | } |
| 592 | |
| 593 | if len(m.properties.Srcs) == 0 { |
| 594 | ctx.PropertyErrorf("srcs", "can't be empty") |
| 595 | return |
| 596 | } |
| 597 | |
| 598 | if proptools.String(m.properties.Sepolicy) == "" { |
| 599 | ctx.PropertyErrorf("sepolicy", "can't be empty") |
| 600 | return |
| 601 | } |
| 602 | |
Thiébaud Weksteen | a69e14f | 2023-10-20 13:31:19 +1100 | [diff] [blame^] | 603 | flags := []string(nil) |
| 604 | switch m.context { |
| 605 | case ServiceContext: |
| 606 | flags = []string{"-s" /* binder services */} |
| 607 | case HwServiceContext: |
| 608 | flags = []string{"-e" /* allow empty */, "-l" /* hwbinder services */} |
| 609 | case VndServiceContext: |
| 610 | flags = []string{"-e" /* allow empty */, "-v" /* vnd service */} |
| 611 | } |
| 612 | |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 613 | srcs := android.PathsForModuleSrc(ctx, m.properties.Srcs) |
| 614 | sepolicy := android.PathForModuleSrc(ctx, proptools.String(m.properties.Sepolicy)) |
| 615 | |
| 616 | rule := android.NewRuleBuilder(pctx, ctx) |
| 617 | rule.Command().BuiltTool(tool). |
Thiébaud Weksteen | a69e14f | 2023-10-20 13:31:19 +1100 | [diff] [blame^] | 618 | Flags(flags). |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 619 | Input(sepolicy). |
| 620 | Inputs(srcs) |
| 621 | |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 622 | m.testTimestamp = pathForModuleOut(ctx, "timestamp") |
Inseob Kim | b5e2353 | 2022-02-16 02:26:11 +0000 | [diff] [blame] | 623 | rule.Command().Text("touch").Output(m.testTimestamp) |
| 624 | rule.Build("contexts_test", "running contexts test: "+ctx.ModuleName()) |
| 625 | } |
| 626 | |
| 627 | func (m *contextsTestModule) AndroidMkEntries() []android.AndroidMkEntries { |
| 628 | return []android.AndroidMkEntries{android.AndroidMkEntries{ |
| 629 | Class: "FAKE", |
| 630 | // OutputFile is needed, even though BUILD_PHONY_PACKAGE doesn't use it. |
| 631 | // Without OutputFile this module won't be exported to Makefile. |
| 632 | OutputFile: android.OptionalPathForPath(m.testTimestamp), |
| 633 | Include: "$(BUILD_PHONY_PACKAGE)", |
| 634 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 635 | func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
| 636 | entries.SetString("LOCAL_ADDITIONAL_DEPENDENCIES", m.testTimestamp.String()) |
| 637 | }, |
| 638 | }, |
| 639 | }} |
| 640 | } |
| 641 | |
| 642 | // contextsTestModule implements ImageInterface to be able to include recovery_available contexts |
| 643 | // modules as its sources. |
| 644 | func (m *contextsTestModule) ImageMutatorBegin(ctx android.BaseModuleContext) { |
| 645 | } |
| 646 | |
| 647 | func (m *contextsTestModule) CoreVariantNeeded(ctx android.BaseModuleContext) bool { |
| 648 | return true |
| 649 | } |
| 650 | |
| 651 | func (m *contextsTestModule) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 652 | return false |
| 653 | } |
| 654 | |
| 655 | func (m *contextsTestModule) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 656 | return false |
| 657 | } |
| 658 | |
| 659 | func (m *contextsTestModule) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 660 | return false |
| 661 | } |
| 662 | |
| 663 | func (m *contextsTestModule) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { |
| 664 | return false |
| 665 | } |
| 666 | |
| 667 | func (m *contextsTestModule) ExtraImageVariations(ctx android.BaseModuleContext) []string { |
| 668 | return nil |
| 669 | } |
| 670 | |
| 671 | func (m *contextsTestModule) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) { |
| 672 | } |
| 673 | |
| 674 | var _ android.ImageInterface = (*contextsTestModule)(nil) |