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// Build rules to build shim apks. 16 17//########################################################## 18// Variant: Privileged app upgrade 19 20package { 21 // See: http://go/android-license-faq 22 // A large-scale-change added 'default_applicable_licenses' to import 23 // all of the 'license_kinds' from "frameworks_base_license" 24 // to get the below license kinds: 25 // SPDX-license-identifier-Apache-2.0 26 default_applicable_licenses: ["frameworks_base_license"], 27} 28 29android_app { 30 name: "CtsShimPrivUpgrade", 31 // this needs to be a privileged application 32 privileged: true, 33 34 sdk_version: "current", 35 optimize: { 36 enabled: false, 37 }, 38 dex_preopt: { 39 enabled: false, 40 }, 41 42 manifest: "shim_priv_upgrade/AndroidManifest.xml", 43 44 compile_multilib: "both", 45 jni_libs: ["libshim_jni"], 46 // Explicitly uncompress native libs rather than letting the build system doing it and destroy the 47 // v2/v3 signature. 48 use_embedded_native_libs: true, 49 50 uses_libs: ["android.test.runner"], 51 52 apex_available: [ 53 "//apex_available:platform", 54 "com.android.apex.cts.shim.v2_apk_in_apex_upgrades", 55 ], 56} 57 58genrule { 59 name: "generate_priv_manifest", 60 srcs: [ 61 "shim_priv/AndroidManifest.xml", 62 ":CtsShimPrivUpgrade", 63 ], 64 out: ["AndroidManifest.xml"], 65 cmd: "sed -e s/__HASH__/`sha512sum -b $(location :CtsShimPrivUpgrade) | cut -d' ' -f1`/ $(location shim_priv/AndroidManifest.xml) > $(out)", 66} 67 68//########################################################## 69// Variant: Privileged app 70 71android_app { 72 name: "CtsShimPriv", 73 // this needs to be a privileged application 74 privileged: true, 75 76 sdk_version: "current", 77 optimize: { 78 enabled: false, 79 }, 80 dex_preopt: { 81 enabled: false, 82 }, 83 84 manifest: ":generate_priv_manifest", 85 86 compile_multilib: "both", 87 jni_libs: ["libshim_jni"], 88 // Explicitly uncompress native libs rather than letting the build system doing it and destroy the 89 // v2/v3 signature. 90 use_embedded_native_libs: true, 91 apex_available: [ 92 "//apex_available:platform", 93 "com.android.apex.cts.shim.v1", 94 "com.android.apex.cts.shim.v2", 95 "com.android.apex.cts.shim.v2_apk_in_apex_upgrades", 96 "com.android.apex.cts.shim.v2_no_hashtree", 97 "com.android.apex.cts.shim.v2_legacy", 98 "com.android.apex.cts.shim.v2_sdk_target_p", 99 "com.android.apex.cts.shim.v2_unsigned_payload", 100 "com.android.apex.cts.shim.v3", 101 ], 102 min_sdk_version: "24", 103} 104 105//########################################################## 106// Variant: Privileged app upgrade w/ the wrong SHA 107 108android_app { 109 name: "CtsShimPrivUpgradeWrongSHA", 110 // this needs to be a privileged application 111 privileged: true, 112 113 sdk_version: "current", 114 optimize: { 115 enabled: false, 116 }, 117 dex_preopt: { 118 enabled: false, 119 }, 120 // anything to make this package's SHA different from CtsShimPrivUpgrade 121 aaptflags: [ 122 "--version-name", 123 "WrongSHA", 124 ], 125 126 manifest: "shim_priv_upgrade/AndroidManifest.xml", 127 128 compile_multilib: "both", 129 jni_libs: ["libshim_jni"], 130 // Explicitly uncompress native libs rather than letting the build system doing it and destroy the 131 // v2/v3 signature. 132 use_embedded_native_libs: true, 133 134 uses_libs: ["android.test.runner"], 135} 136 137//########################################################## 138// Variant: Non Privileged app upgrade which is malformed 139android_app { 140 name: "CtsShimTargetPSdk", 141 sdk_version: "current", 142 optimize: { 143 enabled: false, 144 }, 145 dex_preopt: { 146 enabled: false, 147 }, 148 manifest: "shim/AndroidManifestTargetPSdk.xml", 149 apex_available: [ 150 "//apex_available:platform", 151 "com.android.apex.cts.shim.v2_apk_in_apex_sdk_target_p", 152 ], 153} 154 155//########################################################## 156// Variant: System app upgrade 157 158android_app { 159 name: "CtsShimUpgrade", 160 161 sdk_version: "current", 162 optimize: { 163 enabled: false, 164 }, 165 dex_preopt: { 166 enabled: false, 167 }, 168 169 manifest: "shim/AndroidManifestUpgrade.xml", 170 min_sdk_version: "24", 171} 172 173genrule { 174 name: "generate_shim_manifest", 175 srcs: [ 176 "shim/AndroidManifest.xml", 177 ":CtsShimUpgrade", 178 ], 179 out: ["AndroidManifest.xml"], 180 cmd: "sed -e s/__HASH__/`sha512sum -b $(location :CtsShimUpgrade) | cut -d' ' -f1`/ $(location shim/AndroidManifest.xml) > $(out)", 181} 182 183//########################################################## 184// Variant: System app 185 186android_app { 187 name: "CtsShim", 188 189 sdk_version: "current", 190 optimize: { 191 enabled: false, 192 }, 193 dex_preopt: { 194 enabled: false, 195 }, 196 197 manifest: ":generate_shim_manifest", 198 apex_available: [ 199 "//apex_available:platform", 200 "com.android.apex.cts.shim.v1", 201 "com.android.apex.cts.shim.v2", 202 "com.android.apex.cts.shim.v2_apk_in_apex_upgrades", 203 "com.android.apex.cts.shim.v2_no_hashtree", 204 "com.android.apex.cts.shim.v2_legacy", 205 "com.android.apex.cts.shim.v2_sdk_target_p", 206 "com.android.apex.cts.shim.v2_unsigned_payload", 207 "com.android.apex.cts.shim.v3", 208 ], 209 min_sdk_version: "24", 210} 211