summaryrefslogtreecommitdiff
path: root/packages/CtsShim/build/Android.bp
blob: 0b3f9bb62a9b91f273a19f87f984ecfee2d803e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// Copyright (C) 2019 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Build rules to build shim apks.

//##########################################################
// Variant: Privileged app upgrade

package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_base_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_base_license"],
}

android_app {
    name: "CtsShimPrivUpgrade",
    // this needs to be a privileged application
    privileged: true,

    sdk_version: "current",
    optimize: {
        enabled: false,
    },
    dex_preopt: {
        enabled: false,
    },

    manifest: "shim_priv_upgrade/AndroidManifest.xml",

    compile_multilib: "both",
    jni_libs: ["libshim_jni"],

    uses_libs: ["android.test.runner"],
}

genrule {
  name: "generate_priv_manifest",
  srcs: [
    "shim_priv/AndroidManifest.xml",
    ":CtsShimPrivUpgrade"
  ],
  out: ["AndroidManifest.xml"],
  cmd: "sed -e s/__HASH__/`sha512sum -b $(location :CtsShimPrivUpgrade) | cut -d' ' -f1`/ $(location shim_priv/AndroidManifest.xml) > $(out)",
}

//##########################################################
// Variant: Privileged app

android_app {
    name: "CtsShimPriv",
    // this needs to be a privileged application
    privileged: true,

    sdk_version: "current",
    optimize: {
        enabled: false,
    },
    dex_preopt: {
        enabled: false,
    },

    manifest: ":generate_priv_manifest",

    compile_multilib: "both",
    jni_libs: ["libshim_jni"],
    // Explicitly uncompress native libs rather than letting the build system doing it and destroy the
    // v2/v3 signature.
    use_embedded_native_libs: true,
    apex_available: [
        "//apex_available:platform",
        "com.android.apex.cts.shim.v1",
        "com.android.apex.cts.shim.v2",
        "com.android.apex.cts.shim.v2_no_hashtree",
        "com.android.apex.cts.shim.v2_legacy",
        "com.android.apex.cts.shim.v2_sdk_target_p",
        "com.android.apex.cts.shim.v2_unsigned_payload",
        "com.android.apex.cts.shim.v3",
    ],
    min_sdk_version: "24",
}

//##########################################################
// Variant: Privileged app upgrade w/ the wrong SHA

android_app {
    name: "CtsShimPrivUpgradeWrongSHA",
    // this needs to be a privileged application
    privileged: true,

    sdk_version: "current",
    optimize: {
        enabled: false,
    },
    dex_preopt: {
        enabled: false,
    },
    // anything to make this package's SHA different from CtsShimPrivUpgrade
    aaptflags: [
        "--version-name",
        "WrongSHA",
    ],

    manifest: "shim_priv_upgrade/AndroidManifest.xml",

    compile_multilib: "both",
    jni_libs: ["libshim_jni"],

    uses_libs: ["android.test.runner"],
}

//##########################################################
// Variant: Non Privileged app upgrade which is malformed
android_app {
    name: "CtsShimTargetPSdk",
    sdk_version: "current",
    optimize: {
        enabled: false,
    },
    dex_preopt: {
        enabled: false,
    },
    manifest: "shim/AndroidManifestTargetPSdk.xml",
    apex_available: [
        "//apex_available:platform",
        "com.android.apex.cts.shim.v2_apk_in_apex_sdk_target_p",
    ],
}

//##########################################################
// Variant: System app

android_app {
    name: "CtsShim",

    sdk_version: "current",
    optimize: {
        enabled: false,
    },
    dex_preopt: {
        enabled: false,
    },

    manifest: "shim/AndroidManifest.xml",
    apex_available: [
        "//apex_available:platform",
        "com.android.apex.cts.shim.v1",
        "com.android.apex.cts.shim.v2",
        "com.android.apex.cts.shim.v2_no_hashtree",
        "com.android.apex.cts.shim.v2_legacy",
        "com.android.apex.cts.shim.v2_sdk_target_p",
        "com.android.apex.cts.shim.v2_unsigned_payload",
        "com.android.apex.cts.shim.v3",
    ],
    min_sdk_version: "24",
}