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 58java_genrule { 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_legacy", 97 "com.android.apex.cts.shim.v2_sdk_target_p", 98 "com.android.apex.cts.shim.v2_unsigned_payload", 99 "com.android.apex.cts.shim.v3", 100 ], 101 min_sdk_version: "24", 102} 103 104//########################################################## 105// Variant: Privileged app upgrade w/ the wrong SHA 106 107android_app { 108 name: "CtsShimPrivUpgradeWrongSHA", 109 // this needs to be a privileged application 110 privileged: true, 111 112 sdk_version: "current", 113 optimize: { 114 enabled: false, 115 }, 116 dex_preopt: { 117 enabled: false, 118 }, 119 // anything to make this package's SHA different from CtsShimPrivUpgrade 120 aaptflags: [ 121 "--version-name", 122 "WrongSHA", 123 ], 124 125 manifest: "shim_priv_upgrade/AndroidManifest.xml", 126 127 compile_multilib: "both", 128 jni_libs: ["libshim_jni"], 129 // Explicitly uncompress native libs rather than letting the build system doing it and destroy the 130 // v2/v3 signature. 131 use_embedded_native_libs: true, 132 133 uses_libs: ["android.test.runner"], 134} 135 136//########################################################## 137// Variant: Non Privileged app upgrade which is malformed 138android_app { 139 name: "CtsShimTargetPSdk", 140 sdk_version: "current", 141 optimize: { 142 enabled: false, 143 }, 144 dex_preopt: { 145 enabled: false, 146 }, 147 manifest: "shim/AndroidManifestTargetPSdk.xml", 148 apex_available: [ 149 "//apex_available:platform", 150 "com.android.apex.cts.shim.v2_apk_in_apex_sdk_target_p", 151 ], 152} 153 154//########################################################## 155// Variant: System app upgrade 156 157android_app { 158 name: "CtsShimUpgrade", 159 160 sdk_version: "current", 161 optimize: { 162 enabled: false, 163 }, 164 dex_preopt: { 165 enabled: false, 166 }, 167 168 manifest: "shim/AndroidManifestUpgrade.xml", 169 min_sdk_version: "24", 170} 171 172java_genrule { 173 name: "generate_shim_manifest", 174 srcs: [ 175 "shim/AndroidManifest.xml", 176 ":CtsShimUpgrade", 177 ], 178 out: ["AndroidManifest.xml"], 179 cmd: "sed -e s/__HASH__/`sha512sum -b $(location :CtsShimUpgrade) | cut -d' ' -f1`/ $(location shim/AndroidManifest.xml) > $(out)", 180} 181 182//########################################################## 183// Variant: System app 184 185android_app { 186 name: "CtsShim", 187 188 sdk_version: "current", 189 optimize: { 190 enabled: false, 191 }, 192 dex_preopt: { 193 enabled: false, 194 }, 195 196 manifest: ":generate_shim_manifest", 197 apex_available: [ 198 "//apex_available:platform", 199 "com.android.apex.cts.shim.v1", 200 "com.android.apex.cts.shim.v2", 201 "com.android.apex.cts.shim.v2_apk_in_apex_upgrades", 202 "com.android.apex.cts.shim.v2_legacy", 203 "com.android.apex.cts.shim.v2_sdk_target_p", 204 "com.android.apex.cts.shim.v2_unsigned_payload", 205 "com.android.apex.cts.shim.v3", 206 ], 207 min_sdk_version: "24", 208} 209 210//########################################################## 211// Variant: Add apk to an apex 212android_app { 213 name: "CtsShimAddApkToApex", 214 sdk_version: "current", 215 srcs: ["shim_add_apk_to_apex/src/android/addapktoapex/app/AddApkToApexDeviceActivity.java"], 216 optimize: { 217 enabled: false, 218 }, 219 dex_preopt: { 220 enabled: false, 221 }, 222 manifest: "shim_add_apk_to_apex/AndroidManifestAddApkToApex.xml", 223 apex_available: [ 224 "//apex_available:platform", 225 "com.android.apex.cts.shim.v2_add_apk_to_apex", 226 ], 227} 228