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