1// Copyright 2020 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 15package java 16 17import ( 18 "android/soong/android" 19 "android/soong/java/config" 20) 21 22var legacyCorePlatformApiModules = []string{ 23 "AAECarSystemUI", 24 "AAECarSystemUI-tests", 25 "ArcSettings", 26 "ahat-test-dump", 27 "android.car", 28 "android.test.mock", 29 "android.test.mock.impl", 30 "AoapTestDeviceApp", 31 "AoapTestHostApp", 32 "api-stubs-docs", 33 "art_cts_jvmti_test_library", 34 "art-gtest-jars-MyClassNatives", 35 "BackupEncryption", 36 "BackupFrameworksServicesRoboTests", 37 "backuplib", 38 "BandwidthEnforcementTest", 39 "BlockedNumberProvider", 40 "BluetoothInstrumentationTests", 41 "BluetoothMidiLib", 42 "BluetoothMidiService", 43 "BTTestApp", 44 "CallEnhancement", 45 "CapCtrlInterface", 46 "CarService", 47 "CarServiceTest", 48 "car-service-test-lib", 49 "car-service-test-static-lib", 50 "CertInstaller", 51 "com.qti.location.sdk", 52 "com.qti.media.secureprocessor", 53 "ConnectivityManagerTest", 54 "ContactsProvider", 55 "CorePerfTests", 56 "core-tests-support", 57 "cronet_impl_common_java", 58 "cronet_impl_native_java", 59 "cronet_impl_platform_java", 60 "CtsAppExitTestCases", 61 "CtsContentTestCases", 62 "CtsLibcoreWycheproofBCTestCases", 63 "CtsMediaTestCases", 64 "CtsNetTestCases", 65 "CtsNetTestCasesLatestSdk", 66 "CtsSecurityTestCases", 67 "CtsSuspendAppsTestCases", 68 "CtsUsageStatsTestCases", 69 "DeadpoolService", 70 "DeadpoolServiceBtServices", 71 "DeviceInfo", 72 "DiagnosticTools", 73 "DisplayCutoutEmulationEmu01Overlay", 74 "DocumentsUIGoogleTests", 75 "DocumentsUIPerfTests", 76 "DocumentsUITests", 77 "DocumentsUIUnitTests", 78 "DownloadProvider", 79 "DownloadProviderTests", 80 "DownloadProviderUi", 81 "ds-car-docs", // for AAOS API documentation only 82 "DynamicSystemInstallationService", 83 "EmergencyInfo-lib", 84 "EthernetServiceTests", 85 "ExternalStorageProvider", 86 "face-V1-0-javalib", 87 "FloralClocks", 88 "framework-jobscheduler", 89 "framework-minus-apex", 90 "framework-minus-apex-intdefs", 91 "FrameworkOverlayG6QU3", 92 "FrameworksCoreTests", 93 "FrameworksIkeTests", 94 "FrameworksNetCommonTests", 95 "FrameworksNetTests", 96 "FrameworksServicesRoboTests", 97 "FrameworksServicesTests", 98 "FrameworksMockingServicesTests", 99 "FrameworksUtilTests", 100 "GtsIncrementalInstallTestCases", 101 "GtsIncrementalInstallTriggerApp", 102 "GtsInstallerV2TestCases", 103 "HelloOslo", 104 "hid", 105 "hidl_test_java_java", 106 "hwbinder", 107 "imssettings", 108 "izat.lib.glue", 109 "KeyChain", 110 "LocalSettingsLib", 111 "LocalTransport", 112 "lockagent", 113 "mediaframeworktest", 114 "mediatek-ims-base", 115 "MmsService", 116 "ModemTestMode", 117 "MtkCapCtrl", 118 "MtpService", 119 "MultiDisplayProvider", 120 "my.tests.snapdragonsdktest", 121 "NetworkSetting", 122 "NetworkStackIntegrationTestsLib", 123 "NetworkStackNextIntegrationTests", 124 "NetworkStackNextTests", 125 "NetworkStackTests", 126 "NetworkStackTestsLib", 127 "online-gcm-ref-docs", 128 "online-gts-docs", 129 "PerformanceMode", 130 "platform_library-docs", 131 "PowerStatsService", 132 "PrintSpooler", 133 "pxp-monitor", 134 "QColor", 135 "qcom.fmradio", 136 "QDCMMobileApp", 137 "Qmmi", 138 "QPerformance", 139 "remotesimlockmanagerlibrary", 140 "RollbackTest", 141 "sam", 142 "saminterfacelibrary", 143 "sammanagerlibrary", 144 "service-blobstore", 145 "service-connectivity-pre-jarjar", 146 "service-jobscheduler", 147 "services", 148 "services.accessibility", 149 "services.backup", 150 "services.core.unboosted", 151 "services.devicepolicy", 152 "services.print", 153 "services.usage", 154 "services.usb", 155 "Settings-core", 156 "SettingsGoogle", 157 "SettingsGoogleOverlayCoral", 158 "SettingsGoogleOverlayFlame", 159 "SettingsLib", 160 "SettingsOverlayG020A", 161 "SettingsOverlayG020B", 162 "SettingsOverlayG020C", 163 "SettingsOverlayG020D", 164 "SettingsOverlayG020E", 165 "SettingsOverlayG020E_VN", 166 "SettingsOverlayG020F", 167 "SettingsOverlayG020F_VN", 168 "SettingsOverlayG020G", 169 "SettingsOverlayG020G_VN", 170 "SettingsOverlayG020H", 171 "SettingsOverlayG020H_VN", 172 "SettingsOverlayG020I", 173 "SettingsOverlayG020I_VN", 174 "SettingsOverlayG020J", 175 "SettingsOverlayG020M", 176 "SettingsOverlayG020N", 177 "SettingsOverlayG020P", 178 "SettingsOverlayG020Q", 179 "SettingsOverlayG025H", 180 "SettingsOverlayG025J", 181 "SettingsOverlayG025M", 182 "SettingsOverlayG025N", 183 "SettingsOverlayG5NZ6", 184 "SettingsProvider", 185 "SettingsProviderTest", 186 "SettingsRoboTests", 187 "Shell", 188 "ShellTests", 189 "SimContact", 190 "SimContacts", 191 "SimSettings", 192 "sl4a.Common", 193 "StatementService", 194 "SystemUI-core", 195 "SystemUISharedLib", 196 "SystemUI-tests", 197 "tcmiface", 198 "Telecom", 199 "TelecomUnitTests", 200 "telephony-common", 201 "TelephonyProviderTests", 202 "TeleService", 203 "testables", 204 "TetheringTests", 205 "TetheringTestsLib", 206 "time_zone_distro_installer", 207 "time_zone_distro_installer-tests", 208 "time_zone_distro-tests", 209 "time_zone_updater", 210 "TMobilePlanProvider", 211 "TvProvider", 212 "uiautomator-stubs-docs", 213 "uimgbamanagerlibrary", 214 "UsbHostExternalManagementTestApp", 215 "UserDictionaryProvider", 216 "UxPerformance", 217 "WallpaperBackup", 218 "WallpaperBackupAgentTests", 219 "WfdCommon", 220} 221 222var legacyCorePlatformApiLookup = make(map[string]struct{}) 223 224func init() { 225 for _, module := range legacyCorePlatformApiModules { 226 legacyCorePlatformApiLookup[module] = struct{}{} 227 } 228} 229 230var legacyCorePlatformApiLookupKey = android.NewOnceKey("legacyCorePlatformApiLookup") 231 232func getLegacyCorePlatformApiLookup(config android.Config) map[string]struct{} { 233 return config.Once(legacyCorePlatformApiLookupKey, func() interface{} { 234 return legacyCorePlatformApiLookup 235 }).(map[string]struct{}) 236} 237 238// useLegacyCorePlatformApi checks to see whether the supplied module name is in the list of modules 239// that are able to use the legacy core platform API and returns true if it does, false otherwise. 240// 241// This method takes the module name separately from the context as this may be being called for a 242// module that is not the target of the supplied context. 243func useLegacyCorePlatformApi(ctx android.EarlyModuleContext, moduleName string) bool { 244 lookup := getLegacyCorePlatformApiLookup(ctx.Config()) 245 _, found := lookup[moduleName] 246 return found 247} 248 249func corePlatformSystemModules(ctx android.EarlyModuleContext) string { 250 if useLegacyCorePlatformApi(ctx, ctx.ModuleName()) { 251 return config.LegacyCorePlatformSystemModules 252 } else { 253 return config.StableCorePlatformSystemModules 254 } 255} 256 257func corePlatformBootclasspathLibraries(ctx android.EarlyModuleContext) []string { 258 if useLegacyCorePlatformApi(ctx, ctx.ModuleName()) { 259 return config.LegacyCorePlatformBootclasspathLibraries 260 } else { 261 return config.StableCorePlatformBootclasspathLibraries 262 } 263} 264