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	"ethernet-service",
85	"EthernetServiceTests",
86	"ExternalStorageProvider",
87	"face-V1-0-javalib",
88	"FloralClocks",
89	"framework-jobscheduler",
90	"framework-minus-apex",
91	"framework-minus-apex-intdefs",
92	"FrameworkOverlayG6QU3",
93	"FrameworksCoreTests",
94	"FrameworksIkeTests",
95	"FrameworksNetCommonTests",
96	"FrameworksNetTests",
97	"FrameworksServicesRoboTests",
98	"FrameworksServicesTests",
99	"FrameworksMockingServicesTests",
100	"FrameworksUtilTests",
101	"GtsIncrementalInstallTestCases",
102	"GtsIncrementalInstallTriggerApp",
103	"GtsInstallerV2TestCases",
104	"HelloOslo",
105	"hid",
106	"hidl_test_java_java",
107	"hwbinder",
108	"imssettings",
109	"izat.lib.glue",
110	"KeyChain",
111	"LocalSettingsLib",
112	"LocalTransport",
113	"lockagent",
114	"mediaframeworktest",
115	"mediatek-ims-base",
116	"MmsService",
117	"ModemTestMode",
118	"MtkCapCtrl",
119	"MtpService",
120	"MultiDisplayProvider",
121	"my.tests.snapdragonsdktest",
122	"NetworkSetting",
123	"NetworkStackIntegrationTestsLib",
124	"NetworkStackNextIntegrationTests",
125	"NetworkStackNextTests",
126	"NetworkStackTests",
127	"NetworkStackTestsLib",
128	"online-gcm-ref-docs",
129	"online-gts-docs",
130	"PerformanceMode",
131	"platform_library-docs",
132	"PowerStatsService",
133	"PrintSpooler",
134	"pxp-monitor",
135	"QColor",
136	"qcom.fmradio",
137	"QDCMMobileApp",
138	"Qmmi",
139	"QPerformance",
140	"remotesimlockmanagerlibrary",
141	"RollbackTest",
142	"sam",
143	"saminterfacelibrary",
144	"sammanagerlibrary",
145	"service-blobstore",
146	"service-connectivity-pre-jarjar",
147	"service-jobscheduler",
148	"services",
149	"services.accessibility",
150	"services.backup",
151	"services.core.unboosted",
152	"services.devicepolicy",
153	"services.print",
154	"services.usage",
155	"services.usb",
156	"Settings-core",
157	"SettingsGoogle",
158	"SettingsGoogleOverlayCoral",
159	"SettingsGoogleOverlayFlame",
160	"SettingsLib",
161	"SettingsOverlayG020A",
162	"SettingsOverlayG020B",
163	"SettingsOverlayG020C",
164	"SettingsOverlayG020D",
165	"SettingsOverlayG020E",
166	"SettingsOverlayG020E_VN",
167	"SettingsOverlayG020F",
168	"SettingsOverlayG020F_VN",
169	"SettingsOverlayG020G",
170	"SettingsOverlayG020G_VN",
171	"SettingsOverlayG020H",
172	"SettingsOverlayG020H_VN",
173	"SettingsOverlayG020I",
174	"SettingsOverlayG020I_VN",
175	"SettingsOverlayG020J",
176	"SettingsOverlayG020M",
177	"SettingsOverlayG020N",
178	"SettingsOverlayG020P",
179	"SettingsOverlayG020Q",
180	"SettingsOverlayG025H",
181	"SettingsOverlayG025J",
182	"SettingsOverlayG025M",
183	"SettingsOverlayG025N",
184	"SettingsOverlayG5NZ6",
185	"SettingsProvider",
186	"SettingsProviderTest",
187	"SettingsRoboTests",
188	"Shell",
189	"ShellTests",
190	"SimContact",
191	"SimContacts",
192	"SimSettings",
193	"sl4a.Common",
194	"StatementService",
195	"SystemUI-core",
196	"SystemUISharedLib",
197	"SystemUI-tests",
198	"tcmiface",
199	"Telecom",
200	"TelecomUnitTests",
201	"telephony-common",
202	"TelephonyProviderTests",
203	"TeleService",
204	"testables",
205	"TetheringTests",
206	"TetheringTestsLib",
207	"time_zone_distro_installer",
208	"time_zone_distro_installer-tests",
209	"time_zone_distro-tests",
210	"time_zone_updater",
211	"TMobilePlanProvider",
212	"TvProvider",
213	"uiautomator-stubs-docs",
214	"uimgbamanagerlibrary",
215	"UsbHostExternalManagementTestApp",
216	"UserDictionaryProvider",
217	"UxPerformance",
218	"WallpaperBackup",
219	"WallpaperBackupAgentTests",
220	"WfdCommon",
221}
222
223var legacyCorePlatformApiLookup = make(map[string]struct{})
224
225func init() {
226	for _, module := range legacyCorePlatformApiModules {
227		legacyCorePlatformApiLookup[module] = struct{}{}
228	}
229}
230
231func useLegacyCorePlatformApi(ctx android.EarlyModuleContext) bool {
232	return useLegacyCorePlatformApiByName(ctx.ModuleName())
233}
234
235func useLegacyCorePlatformApiByName(name string) bool {
236	_, found := legacyCorePlatformApiLookup[name]
237	return found
238}
239
240func corePlatformSystemModules(ctx android.EarlyModuleContext) string {
241	if useLegacyCorePlatformApi(ctx) {
242		return config.LegacyCorePlatformSystemModules
243	} else {
244		return config.StableCorePlatformSystemModules
245	}
246}
247
248func corePlatformBootclasspathLibraries(ctx android.EarlyModuleContext) []string {
249	if useLegacyCorePlatformApi(ctx) {
250		return config.LegacyCorePlatformBootclasspathLibraries
251	} else {
252		return config.StableCorePlatformBootclasspathLibraries
253	}
254}
255