| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 1 | // Copyright 2018 Google Inc. All rights reserved. | 
|  | 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 | // The dexpreopt package converts a global dexpreopt config and a module dexpreopt config into rules to perform | 
|  | 16 | // dexpreopting and to strip the dex files from the APK or JAR. | 
|  | 17 | // | 
|  | 18 | // It is used in two places; in the dexpeopt_gen binary for modules defined in Make, and directly linked into Soong. | 
|  | 19 | // | 
|  | 20 | // For Make modules it is built into the dexpreopt_gen binary, which is executed as a Make rule using global config and | 
|  | 21 | // module config specified in JSON files.  The binary writes out two shell scripts, only updating them if they have | 
|  | 22 | // changed.  One script takes an APK or JAR as an input and produces a zip file containing any outputs of preopting, | 
|  | 23 | // in the location they should be on the device.  The Make build rules will unzip the zip file into $(PRODUCT_OUT) when | 
|  | 24 | // installing the APK, which will install the preopt outputs into $(PRODUCT_OUT)/system or $(PRODUCT_OUT)/system_other | 
|  | 25 | // as necessary.  The zip file may be empty if preopting was disabled for any reason.  The second script takes an APK or | 
|  | 26 | // JAR as an input and strips the dex files in it as necessary. | 
|  | 27 | // | 
|  | 28 | // The intermediate shell scripts allow changes to this package or to the global config to regenerate the shell scripts | 
|  | 29 | // but only require re-executing preopting if the script has changed. | 
|  | 30 | // | 
|  | 31 | // For Soong modules this package is linked directly into Soong and run from the java package.  It generates the same | 
|  | 32 | // commands as for make, using athe same global config JSON file used by make, but using a module config structure | 
|  | 33 | // provided by Soong.  The generated commands are then converted into Soong rule and written directly to the ninja file, | 
|  | 34 | // with no extra shell scripts involved. | 
|  | 35 | package dexpreopt | 
|  | 36 |  | 
|  | 37 | import ( | 
|  | 38 | "fmt" | 
|  | 39 | "path/filepath" | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 40 | "runtime" | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 41 | "strings" | 
|  | 42 |  | 
| Colin Cross | feec25b | 2019-01-30 17:32:39 -0800 | [diff] [blame] | 43 | "android/soong/android" | 
|  | 44 |  | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 45 | "github.com/google/blueprint/pathtools" | 
|  | 46 | ) | 
|  | 47 |  | 
|  | 48 | const SystemPartition = "/system/" | 
|  | 49 | const SystemOtherPartition = "/system_other/" | 
|  | 50 |  | 
|  | 51 | // GenerateStripRule generates a set of commands that will take an APK or JAR as an input and strip the dex files if | 
|  | 52 | // they are no longer necessary after preopting. | 
| Colin Cross | feec25b | 2019-01-30 17:32:39 -0800 | [diff] [blame] | 53 | func GenerateStripRule(global GlobalConfig, module ModuleConfig) (rule *android.RuleBuilder, err error) { | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 54 | defer func() { | 
|  | 55 | if r := recover(); r != nil { | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 56 | if _, ok := r.(runtime.Error); ok { | 
|  | 57 | panic(r) | 
|  | 58 | } else if e, ok := r.(error); ok { | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 59 | err = e | 
|  | 60 | rule = nil | 
|  | 61 | } else { | 
|  | 62 | panic(r) | 
|  | 63 | } | 
|  | 64 | } | 
|  | 65 | }() | 
|  | 66 |  | 
|  | 67 | tools := global.Tools | 
|  | 68 |  | 
| Colin Cross | 758290d | 2019-02-01 16:42:32 -0800 | [diff] [blame] | 69 | rule = android.NewRuleBuilder() | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 70 |  | 
|  | 71 | strip := shouldStripDex(module, global) | 
|  | 72 |  | 
|  | 73 | if strip { | 
| Nicolas Geoffray | fa6e9ec | 2019-02-12 13:12:16 +0000 | [diff] [blame] | 74 | if global.NeverAllowStripping { | 
|  | 75 | panic(fmt.Errorf("Stripping requested on %q, though the product does not allow it", module.DexLocation)) | 
|  | 76 | } | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 77 | // Only strips if the dex files are not already uncompressed | 
|  | 78 | rule.Command(). | 
|  | 79 | Textf(`if (zipinfo %s '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then`, module.StripInputPath). | 
|  | 80 | Tool(tools.Zip2zip).FlagWithInput("-i ", module.StripInputPath).FlagWithOutput("-o ", module.StripOutputPath). | 
|  | 81 | FlagWithArg("-x ", `"classes*.dex"`). | 
|  | 82 | Textf(`; else cp -f %s %s; fi`, module.StripInputPath, module.StripOutputPath) | 
|  | 83 | } else { | 
|  | 84 | rule.Command().Text("cp -f").Input(module.StripInputPath).Output(module.StripOutputPath) | 
|  | 85 | } | 
|  | 86 |  | 
|  | 87 | return rule, nil | 
|  | 88 | } | 
|  | 89 |  | 
|  | 90 | // GenerateDexpreoptRule generates a set of commands that will preopt a module based on a GlobalConfig and a | 
|  | 91 | // ModuleConfig.  The produced files and their install locations will be available through rule.Installs(). | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 92 | func GenerateDexpreoptRule(ctx android.PathContext, | 
|  | 93 | global GlobalConfig, module ModuleConfig) (rule *android.RuleBuilder, err error) { | 
|  | 94 |  | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 95 | defer func() { | 
|  | 96 | if r := recover(); r != nil { | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 97 | if _, ok := r.(runtime.Error); ok { | 
|  | 98 | panic(r) | 
|  | 99 | } else if e, ok := r.(error); ok { | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 100 | err = e | 
|  | 101 | rule = nil | 
|  | 102 | } else { | 
|  | 103 | panic(r) | 
|  | 104 | } | 
|  | 105 | } | 
|  | 106 | }() | 
|  | 107 |  | 
| Colin Cross | 758290d | 2019-02-01 16:42:32 -0800 | [diff] [blame] | 108 | rule = android.NewRuleBuilder() | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 109 |  | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 110 | generateProfile := module.ProfileClassListing.Valid() && !global.DisableGenerateProfile | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 111 |  | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 112 | var profile android.WritablePath | 
| Colin Cross | cbed657 | 2019-01-08 17:38:37 -0800 | [diff] [blame] | 113 | if generateProfile { | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 114 | profile = profileCommand(ctx, global, module, rule) | 
| Colin Cross | cbed657 | 2019-01-08 17:38:37 -0800 | [diff] [blame] | 115 | } | 
|  | 116 |  | 
|  | 117 | if !dexpreoptDisabled(global, module) { | 
|  | 118 | // Don't preopt individual boot jars, they will be preopted together. | 
|  | 119 | // This check is outside dexpreoptDisabled because they still need to be stripped. | 
|  | 120 | if !contains(global.BootJars, module.Name) { | 
|  | 121 | appImage := (generateProfile || module.ForceCreateAppImage || global.DefaultAppImages) && | 
|  | 122 | !module.NoCreateAppImage | 
|  | 123 |  | 
|  | 124 | generateDM := shouldGenerateDM(module, global) | 
|  | 125 |  | 
| Colin Cross | c7e40aa | 2019-02-08 21:37:00 -0800 | [diff] [blame] | 126 | for i, arch := range module.Archs { | 
|  | 127 | image := module.DexPreoptImages[i] | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 128 | dexpreoptCommand(ctx, global, module, rule, arch, profile, image, appImage, generateDM) | 
| Colin Cross | cbed657 | 2019-01-08 17:38:37 -0800 | [diff] [blame] | 129 | } | 
|  | 130 | } | 
|  | 131 | } | 
|  | 132 |  | 
|  | 133 | return rule, nil | 
|  | 134 | } | 
|  | 135 |  | 
|  | 136 | func dexpreoptDisabled(global GlobalConfig, module ModuleConfig) bool { | 
|  | 137 | if contains(global.DisablePreoptModules, module.Name) { | 
|  | 138 | return true | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 139 | } | 
|  | 140 |  | 
|  | 141 | // If OnlyPreoptBootImageAndSystemServer=true and module is not in boot class path skip | 
|  | 142 | // Also preopt system server jars since selinux prevents system server from loading anything from | 
|  | 143 | // /data. If we don't do this they will need to be extracted which is not favorable for RAM usage | 
|  | 144 | // or performance. If PreoptExtractedApk is true, we ignore the only preopt boot image options. | 
|  | 145 | if global.OnlyPreoptBootImageAndSystemServer && !contains(global.BootJars, module.Name) && | 
|  | 146 | !contains(global.SystemServerJars, module.Name) && !module.PreoptExtractedApk { | 
| Colin Cross | cbed657 | 2019-01-08 17:38:37 -0800 | [diff] [blame] | 147 | return true | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 148 | } | 
|  | 149 |  | 
| Colin Cross | cbed657 | 2019-01-08 17:38:37 -0800 | [diff] [blame] | 150 | return false | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 151 | } | 
|  | 152 |  | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 153 | func profileCommand(ctx android.PathContext, global GlobalConfig, module ModuleConfig, | 
|  | 154 | rule *android.RuleBuilder) android.WritablePath { | 
|  | 155 |  | 
|  | 156 | profilePath := module.BuildPath.InSameDir(ctx, "profile.prof") | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 157 | profileInstalledPath := module.DexLocation + ".prof" | 
|  | 158 |  | 
|  | 159 | if !module.ProfileIsTextListing { | 
|  | 160 | rule.Command().FlagWithOutput("touch ", profilePath) | 
|  | 161 | } | 
|  | 162 |  | 
|  | 163 | cmd := rule.Command(). | 
|  | 164 | Text(`ANDROID_LOG_TAGS="*:e"`). | 
|  | 165 | Tool(global.Tools.Profman) | 
|  | 166 |  | 
|  | 167 | if module.ProfileIsTextListing { | 
|  | 168 | // The profile is a test listing of classes (used for framework jars). | 
|  | 169 | // We need to generate the actual binary profile before being able to compile. | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 170 | cmd.FlagWithInput("--create-profile-from=", module.ProfileClassListing.Path()) | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 171 | } else { | 
|  | 172 | // The profile is binary profile (used for apps). Run it through profman to | 
|  | 173 | // ensure the profile keys match the apk. | 
|  | 174 | cmd. | 
|  | 175 | Flag("--copy-and-update-profile-key"). | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 176 | FlagWithInput("--profile-file=", module.ProfileClassListing.Path()) | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 177 | } | 
|  | 178 |  | 
|  | 179 | cmd. | 
|  | 180 | FlagWithInput("--apk=", module.DexPath). | 
|  | 181 | Flag("--dex-location="+module.DexLocation). | 
|  | 182 | FlagWithOutput("--reference-profile-file=", profilePath) | 
|  | 183 |  | 
|  | 184 | if !module.ProfileIsTextListing { | 
|  | 185 | cmd.Text(fmt.Sprintf(`|| echo "Profile out of date for %s"`, module.DexPath)) | 
|  | 186 | } | 
|  | 187 | rule.Install(profilePath, profileInstalledPath) | 
|  | 188 |  | 
|  | 189 | return profilePath | 
|  | 190 | } | 
|  | 191 |  | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 192 | func dexpreoptCommand(ctx android.PathContext, global GlobalConfig, module ModuleConfig, rule *android.RuleBuilder, | 
|  | 193 | arch android.ArchType, profile, bootImage android.Path, appImage, generateDM bool) { | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 194 |  | 
|  | 195 | // HACK: make soname in Soong-generated .odex files match Make. | 
|  | 196 | base := filepath.Base(module.DexLocation) | 
|  | 197 | if filepath.Ext(base) == ".jar" { | 
|  | 198 | base = "javalib.jar" | 
|  | 199 | } else if filepath.Ext(base) == ".apk" { | 
|  | 200 | base = "package.apk" | 
|  | 201 | } | 
|  | 202 |  | 
|  | 203 | toOdexPath := func(path string) string { | 
|  | 204 | return filepath.Join( | 
|  | 205 | filepath.Dir(path), | 
|  | 206 | "oat", | 
| Colin Cross | 74ba962 | 2019-02-11 15:11:14 -0800 | [diff] [blame] | 207 | arch.String(), | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 208 | pathtools.ReplaceExtension(filepath.Base(path), "odex")) | 
|  | 209 | } | 
|  | 210 |  | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 211 | odexPath := module.BuildPath.InSameDir(ctx, "oat", arch.String(), pathtools.ReplaceExtension(base, "odex")) | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 212 | odexInstallPath := toOdexPath(module.DexLocation) | 
|  | 213 | if odexOnSystemOther(module, global) { | 
|  | 214 | odexInstallPath = strings.Replace(odexInstallPath, SystemPartition, SystemOtherPartition, 1) | 
|  | 215 | } | 
|  | 216 |  | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 217 | vdexPath := odexPath.ReplaceExtension(ctx, "vdex") | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 218 | vdexInstallPath := pathtools.ReplaceExtension(odexInstallPath, "vdex") | 
|  | 219 |  | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 220 | invocationPath := odexPath.ReplaceExtension(ctx, "invocation") | 
| Alex Light | 5de4196 | 2018-12-18 15:16:26 -0800 | [diff] [blame] | 221 |  | 
| Colin Cross | c7e40aa | 2019-02-08 21:37:00 -0800 | [diff] [blame] | 222 | // bootImage is .../dex_bootjars/system/framework/arm64/boot.art, but dex2oat wants | 
|  | 223 | // .../dex_bootjars/system/framework/boot.art on the command line | 
|  | 224 | var bootImageLocation string | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 225 | if bootImage != nil { | 
| Colin Cross | c7e40aa | 2019-02-08 21:37:00 -0800 | [diff] [blame] | 226 | bootImageLocation = PathToLocation(bootImage, arch) | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 227 | } | 
|  | 228 |  | 
|  | 229 | // Lists of used and optional libraries from the build config to be verified against the manifest in the APK | 
|  | 230 | var verifyUsesLibs []string | 
|  | 231 | var verifyOptionalUsesLibs []string | 
|  | 232 |  | 
|  | 233 | // Lists of used and optional libraries from the build config, with optional libraries that are known to not | 
|  | 234 | // be present in the current product removed. | 
|  | 235 | var filteredUsesLibs []string | 
|  | 236 | var filteredOptionalUsesLibs []string | 
|  | 237 |  | 
|  | 238 | // The class loader context using paths in the build | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 239 | var classLoaderContextHost android.Paths | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 240 |  | 
|  | 241 | // The class loader context using paths as they will be on the device | 
|  | 242 | var classLoaderContextTarget []string | 
|  | 243 |  | 
|  | 244 | // Extra paths that will be appended to the class loader if the APK manifest has targetSdkVersion < 28 | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 245 | var conditionalClassLoaderContextHost28 android.Paths | 
| Nicolas Geoffray | 05aa7d2 | 2018-12-18 14:15:12 +0000 | [diff] [blame] | 246 | var conditionalClassLoaderContextTarget28 []string | 
|  | 247 |  | 
|  | 248 | // Extra paths that will be appended to the class loader if the APK manifest has targetSdkVersion < 29 | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 249 | var conditionalClassLoaderContextHost29 android.Paths | 
| Nicolas Geoffray | 05aa7d2 | 2018-12-18 14:15:12 +0000 | [diff] [blame] | 250 | var conditionalClassLoaderContextTarget29 []string | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 251 |  | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 252 | var classLoaderContextHostString string | 
|  | 253 |  | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 254 | if module.EnforceUsesLibraries { | 
|  | 255 | verifyUsesLibs = copyOf(module.UsesLibraries) | 
|  | 256 | verifyOptionalUsesLibs = copyOf(module.OptionalUsesLibraries) | 
|  | 257 |  | 
|  | 258 | filteredOptionalUsesLibs = filterOut(global.MissingUsesLibraries, module.OptionalUsesLibraries) | 
|  | 259 | filteredUsesLibs = append(copyOf(module.UsesLibraries), filteredOptionalUsesLibs...) | 
|  | 260 |  | 
|  | 261 | // Create class loader context for dex2oat from uses libraries and filtered optional libraries | 
|  | 262 | for _, l := range filteredUsesLibs { | 
|  | 263 |  | 
|  | 264 | classLoaderContextHost = append(classLoaderContextHost, | 
|  | 265 | pathForLibrary(module, l)) | 
|  | 266 | classLoaderContextTarget = append(classLoaderContextTarget, | 
|  | 267 | filepath.Join("/system/framework", l+".jar")) | 
|  | 268 | } | 
|  | 269 |  | 
|  | 270 | const httpLegacy = "org.apache.http.legacy" | 
|  | 271 | const httpLegacyImpl = "org.apache.http.legacy.impl" | 
|  | 272 |  | 
|  | 273 | // Fix up org.apache.http.legacy.impl since it should be org.apache.http.legacy in the manifest. | 
|  | 274 | replace(verifyUsesLibs, httpLegacyImpl, httpLegacy) | 
|  | 275 | replace(verifyOptionalUsesLibs, httpLegacyImpl, httpLegacy) | 
|  | 276 |  | 
|  | 277 | if !contains(verifyUsesLibs, httpLegacy) && !contains(verifyOptionalUsesLibs, httpLegacy) { | 
| Nicolas Geoffray | 05aa7d2 | 2018-12-18 14:15:12 +0000 | [diff] [blame] | 278 | conditionalClassLoaderContextHost28 = append(conditionalClassLoaderContextHost28, | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 279 | pathForLibrary(module, httpLegacyImpl)) | 
| Nicolas Geoffray | 05aa7d2 | 2018-12-18 14:15:12 +0000 | [diff] [blame] | 280 | conditionalClassLoaderContextTarget28 = append(conditionalClassLoaderContextTarget28, | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 281 | filepath.Join("/system/framework", httpLegacyImpl+".jar")) | 
|  | 282 | } | 
| Nicolas Geoffray | 05aa7d2 | 2018-12-18 14:15:12 +0000 | [diff] [blame] | 283 |  | 
|  | 284 | const hidlBase = "android.hidl.base-V1.0-java" | 
|  | 285 | const hidlManager = "android.hidl.manager-V1.0-java" | 
|  | 286 |  | 
|  | 287 | conditionalClassLoaderContextHost29 = append(conditionalClassLoaderContextHost29, | 
| Alex Light | 5de4196 | 2018-12-18 15:16:26 -0800 | [diff] [blame] | 288 | pathForLibrary(module, hidlManager)) | 
| Nicolas Geoffray | 05aa7d2 | 2018-12-18 14:15:12 +0000 | [diff] [blame] | 289 | conditionalClassLoaderContextTarget29 = append(conditionalClassLoaderContextTarget29, | 
|  | 290 | filepath.Join("/system/framework", hidlManager+".jar")) | 
|  | 291 | conditionalClassLoaderContextHost29 = append(conditionalClassLoaderContextHost29, | 
| Alex Light | 5de4196 | 2018-12-18 15:16:26 -0800 | [diff] [blame] | 292 | pathForLibrary(module, hidlBase)) | 
| Nicolas Geoffray | 05aa7d2 | 2018-12-18 14:15:12 +0000 | [diff] [blame] | 293 | conditionalClassLoaderContextTarget29 = append(conditionalClassLoaderContextTarget29, | 
|  | 294 | filepath.Join("/system/framework", hidlBase+".jar")) | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 295 |  | 
|  | 296 | classLoaderContextHostString = strings.Join(classLoaderContextHost.Strings(), ":") | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 297 | } else { | 
|  | 298 | // Pass special class loader context to skip the classpath and collision check. | 
|  | 299 | // This will get removed once LOCAL_USES_LIBRARIES is enforced. | 
|  | 300 | // Right now LOCAL_USES_LIBRARIES is opt in, for the case where it's not specified we still default | 
|  | 301 | // to the &. | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 302 | classLoaderContextHostString = `\&` | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 303 | } | 
|  | 304 |  | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 305 | rule.Command().FlagWithArg("mkdir -p ", filepath.Dir(odexPath.String())) | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 306 | rule.Command().FlagWithOutput("rm -f ", odexPath) | 
|  | 307 | // Set values in the environment of the rule.  These may be modified by construct_context.sh. | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 308 | rule.Command().FlagWithArg("class_loader_context_arg=--class-loader-context=", classLoaderContextHostString) | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 309 | rule.Command().Text(`stored_class_loader_context_arg=""`) | 
|  | 310 |  | 
|  | 311 | if module.EnforceUsesLibraries { | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 312 | rule.Command().Textf(`uses_library_names="%s"`, strings.Join(verifyUsesLibs, " ")) | 
|  | 313 | rule.Command().Textf(`optional_uses_library_names="%s"`, strings.Join(verifyOptionalUsesLibs, " ")) | 
|  | 314 | rule.Command().Textf(`aapt_binary="%s"`, global.Tools.Aapt) | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 315 | rule.Command().Textf(`dex_preopt_host_libraries="%s"`, | 
|  | 316 | strings.Join(classLoaderContextHost.Strings(), " ")). | 
|  | 317 | Implicits(classLoaderContextHost) | 
|  | 318 | rule.Command().Textf(`dex_preopt_target_libraries="%s"`, | 
|  | 319 | strings.Join(classLoaderContextTarget, " ")) | 
|  | 320 | rule.Command().Textf(`conditional_host_libs_28="%s"`, | 
|  | 321 | strings.Join(conditionalClassLoaderContextHost28.Strings(), " ")). | 
|  | 322 | Implicits(conditionalClassLoaderContextHost28) | 
|  | 323 | rule.Command().Textf(`conditional_target_libs_28="%s"`, | 
|  | 324 | strings.Join(conditionalClassLoaderContextTarget28, " ")) | 
|  | 325 | rule.Command().Textf(`conditional_host_libs_29="%s"`, | 
|  | 326 | strings.Join(conditionalClassLoaderContextHost29.Strings(), " ")). | 
|  | 327 | Implicits(conditionalClassLoaderContextHost29) | 
|  | 328 | rule.Command().Textf(`conditional_target_libs_29="%s"`, | 
|  | 329 | strings.Join(conditionalClassLoaderContextTarget29, " ")) | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 330 | rule.Command().Text("source").Tool(global.Tools.VerifyUsesLibraries).Input(module.DexPath) | 
| Nicolas Geoffray | 05aa7d2 | 2018-12-18 14:15:12 +0000 | [diff] [blame] | 331 | rule.Command().Text("source").Tool(global.Tools.ConstructContext) | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 332 | } | 
|  | 333 |  | 
| Nicolas Geoffray | 2464ef4 | 2019-03-05 14:07:07 +0000 | [diff] [blame] | 334 | // Devices that do not have a product partition use a symlink from /product to /system/product. | 
|  | 335 | // Because on-device dexopt will see dex locations starting with /product, we change the paths | 
|  | 336 | // to mimic this behavior. | 
|  | 337 | dexLocationArg := module.DexLocation | 
|  | 338 | if strings.HasPrefix(dexLocationArg, "/system/product/") { | 
|  | 339 | dexLocationArg = strings.TrimPrefix(dexLocationArg, "/system") | 
|  | 340 | } | 
|  | 341 |  | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 342 | cmd := rule.Command(). | 
|  | 343 | Text(`ANDROID_LOG_TAGS="*:e"`). | 
|  | 344 | Tool(global.Tools.Dex2oat). | 
|  | 345 | Flag("--avoid-storing-invocation"). | 
| Alex Light | 5de4196 | 2018-12-18 15:16:26 -0800 | [diff] [blame] | 346 | FlagWithOutput("--write-invocation-to=", invocationPath).ImplicitOutput(invocationPath). | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 347 | Flag("--runtime-arg").FlagWithArg("-Xms", global.Dex2oatXms). | 
|  | 348 | Flag("--runtime-arg").FlagWithArg("-Xmx", global.Dex2oatXmx). | 
| Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 349 | Flag("--runtime-arg").FlagWithInputList("-Xbootclasspath:", module.PreoptBootClassPathDexFiles, ":"). | 
|  | 350 | Flag("--runtime-arg").FlagWithList("-Xbootclasspath-locations:", module.PreoptBootClassPathDexLocations, ":"). | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 351 | Flag("${class_loader_context_arg}"). | 
|  | 352 | Flag("${stored_class_loader_context_arg}"). | 
| Colin Cross | c7e40aa | 2019-02-08 21:37:00 -0800 | [diff] [blame] | 353 | FlagWithArg("--boot-image=", bootImageLocation).Implicit(bootImage). | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 354 | FlagWithInput("--dex-file=", module.DexPath). | 
| Nicolas Geoffray | 2464ef4 | 2019-03-05 14:07:07 +0000 | [diff] [blame] | 355 | FlagWithArg("--dex-location=", dexLocationArg). | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 356 | FlagWithOutput("--oat-file=", odexPath).ImplicitOutput(vdexPath). | 
|  | 357 | // Pass an empty directory, dex2oat shouldn't be reading arbitrary files | 
|  | 358 | FlagWithArg("--android-root=", global.EmptyDirectory). | 
| Colin Cross | 74ba962 | 2019-02-11 15:11:14 -0800 | [diff] [blame] | 359 | FlagWithArg("--instruction-set=", arch.String()). | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 360 | FlagWithArg("--instruction-set-variant=", global.CpuVariant[arch]). | 
|  | 361 | FlagWithArg("--instruction-set-features=", global.InstructionSetFeatures[arch]). | 
|  | 362 | Flag("--no-generate-debug-info"). | 
|  | 363 | Flag("--generate-build-id"). | 
|  | 364 | Flag("--abort-on-hard-verifier-error"). | 
|  | 365 | Flag("--force-determinism"). | 
|  | 366 | FlagWithArg("--no-inline-from=", "core-oj.jar") | 
|  | 367 |  | 
|  | 368 | var preoptFlags []string | 
|  | 369 | if len(module.PreoptFlags) > 0 { | 
|  | 370 | preoptFlags = module.PreoptFlags | 
|  | 371 | } else if len(global.PreoptFlags) > 0 { | 
|  | 372 | preoptFlags = global.PreoptFlags | 
|  | 373 | } | 
|  | 374 |  | 
|  | 375 | if len(preoptFlags) > 0 { | 
|  | 376 | cmd.Text(strings.Join(preoptFlags, " ")) | 
|  | 377 | } | 
|  | 378 |  | 
|  | 379 | if module.UncompressedDex { | 
|  | 380 | cmd.FlagWithArg("--copy-dex-files=", "false") | 
|  | 381 | } | 
|  | 382 |  | 
|  | 383 | if !anyHavePrefix(preoptFlags, "--compiler-filter=") { | 
|  | 384 | var compilerFilter string | 
|  | 385 | if contains(global.SystemServerJars, module.Name) { | 
|  | 386 | // Jars of system server, use the product option if it is set, speed otherwise. | 
|  | 387 | if global.SystemServerCompilerFilter != "" { | 
|  | 388 | compilerFilter = global.SystemServerCompilerFilter | 
|  | 389 | } else { | 
|  | 390 | compilerFilter = "speed" | 
|  | 391 | } | 
|  | 392 | } else if contains(global.SpeedApps, module.Name) || contains(global.SystemServerApps, module.Name) { | 
|  | 393 | // Apps loaded into system server, and apps the product default to being compiled with the | 
|  | 394 | // 'speed' compiler filter. | 
|  | 395 | compilerFilter = "speed" | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 396 | } else if profile != nil { | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 397 | // For non system server jars, use speed-profile when we have a profile. | 
|  | 398 | compilerFilter = "speed-profile" | 
|  | 399 | } else if global.DefaultCompilerFilter != "" { | 
|  | 400 | compilerFilter = global.DefaultCompilerFilter | 
|  | 401 | } else { | 
|  | 402 | compilerFilter = "quicken" | 
|  | 403 | } | 
|  | 404 | cmd.FlagWithArg("--compiler-filter=", compilerFilter) | 
|  | 405 | } | 
|  | 406 |  | 
|  | 407 | if generateDM { | 
|  | 408 | cmd.FlagWithArg("--copy-dex-files=", "false") | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 409 | dmPath := module.BuildPath.InSameDir(ctx, "generated.dm") | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 410 | dmInstalledPath := pathtools.ReplaceExtension(module.DexLocation, "dm") | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 411 | tmpPath := module.BuildPath.InSameDir(ctx, "primary.vdex") | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 412 | rule.Command().Text("cp -f").Input(vdexPath).Output(tmpPath) | 
|  | 413 | rule.Command().Tool(global.Tools.SoongZip). | 
|  | 414 | FlagWithArg("-L", "9"). | 
|  | 415 | FlagWithOutput("-o", dmPath). | 
|  | 416 | Flag("-j"). | 
|  | 417 | Input(tmpPath) | 
|  | 418 | rule.Install(dmPath, dmInstalledPath) | 
|  | 419 | } | 
|  | 420 |  | 
|  | 421 | // By default, emit debug info. | 
|  | 422 | debugInfo := true | 
|  | 423 | if global.NoDebugInfo { | 
|  | 424 | // If the global setting suppresses mini-debug-info, disable it. | 
|  | 425 | debugInfo = false | 
|  | 426 | } | 
|  | 427 |  | 
|  | 428 | // PRODUCT_SYSTEM_SERVER_DEBUG_INFO overrides WITH_DEXPREOPT_DEBUG_INFO. | 
|  | 429 | // PRODUCT_OTHER_JAVA_DEBUG_INFO overrides WITH_DEXPREOPT_DEBUG_INFO. | 
|  | 430 | if contains(global.SystemServerJars, module.Name) { | 
|  | 431 | if global.AlwaysSystemServerDebugInfo { | 
|  | 432 | debugInfo = true | 
|  | 433 | } else if global.NeverSystemServerDebugInfo { | 
|  | 434 | debugInfo = false | 
|  | 435 | } | 
|  | 436 | } else { | 
|  | 437 | if global.AlwaysOtherDebugInfo { | 
|  | 438 | debugInfo = true | 
|  | 439 | } else if global.NeverOtherDebugInfo { | 
|  | 440 | debugInfo = false | 
|  | 441 | } | 
|  | 442 | } | 
|  | 443 |  | 
|  | 444 | // Never enable on eng. | 
|  | 445 | if global.IsEng { | 
|  | 446 | debugInfo = false | 
|  | 447 | } | 
|  | 448 |  | 
|  | 449 | if debugInfo { | 
|  | 450 | cmd.Flag("--generate-mini-debug-info") | 
|  | 451 | } else { | 
|  | 452 | cmd.Flag("--no-generate-mini-debug-info") | 
|  | 453 | } | 
|  | 454 |  | 
|  | 455 | // Set the compiler reason to 'prebuilt' to identify the oat files produced | 
|  | 456 | // during the build, as opposed to compiled on the device. | 
|  | 457 | cmd.FlagWithArg("--compilation-reason=", "prebuilt") | 
|  | 458 |  | 
|  | 459 | if appImage { | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 460 | appImagePath := odexPath.ReplaceExtension(ctx, "art") | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 461 | appImageInstallPath := pathtools.ReplaceExtension(odexInstallPath, "art") | 
|  | 462 | cmd.FlagWithOutput("--app-image-file=", appImagePath). | 
|  | 463 | FlagWithArg("--image-format=", "lz4") | 
| Mathieu Chartier | 8910722 | 2019-04-29 09:33:50 -0700 | [diff] [blame] | 464 | if !global.DontResolveStartupStrings { | 
|  | 465 | cmd.FlagWithArg("--resolve-startup-const-strings=", "true") | 
|  | 466 | } | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 467 | rule.Install(appImagePath, appImageInstallPath) | 
|  | 468 | } | 
|  | 469 |  | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 470 | if profile != nil { | 
|  | 471 | cmd.FlagWithInput("--profile-file=", profile) | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 472 | } | 
|  | 473 |  | 
|  | 474 | rule.Install(odexPath, odexInstallPath) | 
|  | 475 | rule.Install(vdexPath, vdexInstallPath) | 
|  | 476 | } | 
|  | 477 |  | 
|  | 478 | // Return if the dex file in the APK should be stripped.  If an APK is found to contain uncompressed dex files at | 
|  | 479 | // dex2oat time it will not be stripped even if strip=true. | 
|  | 480 | func shouldStripDex(module ModuleConfig, global GlobalConfig) bool { | 
|  | 481 | strip := !global.DefaultNoStripping | 
|  | 482 |  | 
| Colin Cross | cbed657 | 2019-01-08 17:38:37 -0800 | [diff] [blame] | 483 | if dexpreoptDisabled(global, module) { | 
|  | 484 | strip = false | 
|  | 485 | } | 
|  | 486 |  | 
| Colin Cross | 8c6d250 | 2019-01-09 21:09:14 -0800 | [diff] [blame] | 487 | if module.NoStripping { | 
|  | 488 | strip = false | 
|  | 489 | } | 
|  | 490 |  | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 491 | // Don't strip modules that are not on the system partition in case the oat/vdex version in system ROM | 
|  | 492 | // doesn't match the one in other partitions. It needs to be able to fall back to the APK for that case. | 
|  | 493 | if !strings.HasPrefix(module.DexLocation, SystemPartition) { | 
|  | 494 | strip = false | 
|  | 495 | } | 
|  | 496 |  | 
|  | 497 | // system_other isn't there for an OTA, so don't strip if module is on system, and odex is on system_other. | 
|  | 498 | if odexOnSystemOther(module, global) { | 
|  | 499 | strip = false | 
|  | 500 | } | 
|  | 501 |  | 
|  | 502 | if module.HasApkLibraries { | 
|  | 503 | strip = false | 
|  | 504 | } | 
|  | 505 |  | 
|  | 506 | // Don't strip with dex files we explicitly uncompress (dexopt will not store the dex code). | 
|  | 507 | if module.UncompressedDex { | 
|  | 508 | strip = false | 
|  | 509 | } | 
|  | 510 |  | 
|  | 511 | if shouldGenerateDM(module, global) { | 
|  | 512 | strip = false | 
|  | 513 | } | 
|  | 514 |  | 
|  | 515 | if module.PresignedPrebuilt { | 
|  | 516 | // Only strip out files if we can re-sign the package. | 
|  | 517 | strip = false | 
|  | 518 | } | 
|  | 519 |  | 
|  | 520 | return strip | 
|  | 521 | } | 
|  | 522 |  | 
|  | 523 | func shouldGenerateDM(module ModuleConfig, global GlobalConfig) bool { | 
|  | 524 | // Generating DM files only makes sense for verify, avoid doing for non verify compiler filter APKs. | 
|  | 525 | // No reason to use a dm file if the dex is already uncompressed. | 
|  | 526 | return global.GenerateDMFiles && !module.UncompressedDex && | 
|  | 527 | contains(module.PreoptFlags, "--compiler-filter=verify") | 
|  | 528 | } | 
|  | 529 |  | 
| Nicolas Geoffray | fa6e9ec | 2019-02-12 13:12:16 +0000 | [diff] [blame] | 530 | func OdexOnSystemOtherByName(name string, dexLocation string, global GlobalConfig) bool { | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 531 | if !global.HasSystemOther { | 
|  | 532 | return false | 
|  | 533 | } | 
|  | 534 |  | 
|  | 535 | if global.SanitizeLite { | 
|  | 536 | return false | 
|  | 537 | } | 
|  | 538 |  | 
| Nicolas Geoffray | fa6e9ec | 2019-02-12 13:12:16 +0000 | [diff] [blame] | 539 | if contains(global.SpeedApps, name) || contains(global.SystemServerApps, name) { | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 540 | return false | 
|  | 541 | } | 
|  | 542 |  | 
|  | 543 | for _, f := range global.PatternsOnSystemOther { | 
| Nicolas Geoffray | fa6e9ec | 2019-02-12 13:12:16 +0000 | [diff] [blame] | 544 | if makefileMatch(filepath.Join(SystemPartition, f), dexLocation) { | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 545 | return true | 
|  | 546 | } | 
|  | 547 | } | 
|  | 548 |  | 
|  | 549 | return false | 
|  | 550 | } | 
|  | 551 |  | 
| Nicolas Geoffray | fa6e9ec | 2019-02-12 13:12:16 +0000 | [diff] [blame] | 552 | func odexOnSystemOther(module ModuleConfig, global GlobalConfig) bool { | 
|  | 553 | return OdexOnSystemOtherByName(module.Name, module.DexLocation, global) | 
|  | 554 | } | 
|  | 555 |  | 
| Colin Cross | c7e40aa | 2019-02-08 21:37:00 -0800 | [diff] [blame] | 556 | // PathToLocation converts .../system/framework/arm64/boot.art to .../system/framework/boot.art | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 557 | func PathToLocation(path android.Path, arch android.ArchType) string { | 
|  | 558 | pathArch := filepath.Base(filepath.Dir(path.String())) | 
| Colin Cross | 74ba962 | 2019-02-11 15:11:14 -0800 | [diff] [blame] | 559 | if pathArch != arch.String() { | 
|  | 560 | panic(fmt.Errorf("last directory in %q must be %q", path, arch.String())) | 
| Colin Cross | c7e40aa | 2019-02-08 21:37:00 -0800 | [diff] [blame] | 561 | } | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 562 | return filepath.Join(filepath.Dir(filepath.Dir(path.String())), filepath.Base(path.String())) | 
| Colin Cross | c7e40aa | 2019-02-08 21:37:00 -0800 | [diff] [blame] | 563 | } | 
|  | 564 |  | 
| Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 565 | func pathForLibrary(module ModuleConfig, lib string) android.Path { | 
|  | 566 | path, ok := module.LibraryPaths[lib] | 
|  | 567 | if !ok { | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 568 | panic(fmt.Errorf("unknown library path for %q", lib)) | 
|  | 569 | } | 
|  | 570 | return path | 
|  | 571 | } | 
|  | 572 |  | 
|  | 573 | func makefileMatch(pattern, s string) bool { | 
|  | 574 | percent := strings.IndexByte(pattern, '%') | 
|  | 575 | switch percent { | 
|  | 576 | case -1: | 
|  | 577 | return pattern == s | 
|  | 578 | case len(pattern) - 1: | 
|  | 579 | return strings.HasPrefix(s, pattern[:len(pattern)-1]) | 
|  | 580 | default: | 
|  | 581 | panic(fmt.Errorf("unsupported makefile pattern %q", pattern)) | 
|  | 582 | } | 
|  | 583 | } | 
|  | 584 |  | 
|  | 585 | func contains(l []string, s string) bool { | 
|  | 586 | for _, e := range l { | 
|  | 587 | if e == s { | 
|  | 588 | return true | 
|  | 589 | } | 
|  | 590 | } | 
|  | 591 | return false | 
|  | 592 | } | 
|  | 593 |  | 
|  | 594 | // remove all elements in a from b, returning a new slice | 
|  | 595 | func filterOut(a []string, b []string) []string { | 
|  | 596 | var ret []string | 
|  | 597 | for _, x := range b { | 
|  | 598 | if !contains(a, x) { | 
|  | 599 | ret = append(ret, x) | 
|  | 600 | } | 
|  | 601 | } | 
|  | 602 | return ret | 
|  | 603 | } | 
|  | 604 |  | 
|  | 605 | func replace(l []string, from, to string) { | 
|  | 606 | for i := range l { | 
|  | 607 | if l[i] == from { | 
|  | 608 | l[i] = to | 
|  | 609 | } | 
|  | 610 | } | 
|  | 611 | } | 
|  | 612 |  | 
| Colin Cross | 454c087 | 2019-02-15 23:03:34 -0800 | [diff] [blame] | 613 | var copyOf = android.CopyOf | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 614 |  | 
|  | 615 | func anyHavePrefix(l []string, prefix string) bool { | 
|  | 616 | for _, x := range l { | 
|  | 617 | if strings.HasPrefix(x, prefix) { | 
|  | 618 | return true | 
|  | 619 | } | 
|  | 620 | } | 
|  | 621 | return false | 
|  | 622 | } |