• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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	"ArcSettings",
24	"BTTestApp",
25	"CapCtrlInterface",
26	"com.qti.location.sdk",
27	"face-V1-0-javalib",
28	"FloralClocks",
29	"framework-jobscheduler",
30	"framework-minus-apex",
31	"framework-minus-apex-intdefs",
32	"FrameworksCoreTests",
33	"HelloOslo",
34	"izat.lib.glue",
35	"mediatek-ims-base",
36	"ModemTestMode",
37	"MtkCapCtrl",
38	"my.tests.snapdragonsdktest",
39	"NetworkSetting",
40	"PerformanceMode",
41	"pxp-monitor",
42	"QColor",
43	"qcom.fmradio",
44	"Qmmi",
45	"QPerformance",
46	"sam",
47	"saminterfacelibrary",
48	"sammanagerlibrary",
49	"services",
50	"services.core.unboosted",
51	"Settings-core",
52	"SettingsGoogle",
53	"SettingsGoogleOverlayCoral",
54	"SettingsGoogleOverlayFlame",
55	"SettingsLib",
56	"SettingsRoboTests",
57	"SimContact",
58	"SimContacts",
59	"SimSettings",
60	"tcmiface",
61	"telephony-common",
62	"TeleService",
63	"UxPerformance",
64	"WfdCommon",
65}
66
67var legacyCorePlatformApiLookup = make(map[string]struct{})
68
69func init() {
70	for _, module := range legacyCorePlatformApiModules {
71		legacyCorePlatformApiLookup[module] = struct{}{}
72	}
73}
74
75var legacyCorePlatformApiLookupKey = android.NewOnceKey("legacyCorePlatformApiLookup")
76
77func getLegacyCorePlatformApiLookup(config android.Config) map[string]struct{} {
78	return config.Once(legacyCorePlatformApiLookupKey, func() interface{} {
79		return legacyCorePlatformApiLookup
80	}).(map[string]struct{})
81}
82
83// useLegacyCorePlatformApi checks to see whether the supplied module name is in the list of modules
84// that are able to use the legacy core platform API and returns true if it does, false otherwise.
85//
86// This method takes the module name separately from the context as this may be being called for a
87// module that is not the target of the supplied context.
88func useLegacyCorePlatformApi(ctx android.EarlyModuleContext, moduleName string) bool {
89	lookup := getLegacyCorePlatformApiLookup(ctx.Config())
90	_, found := lookup[moduleName]
91	return found
92}
93
94func corePlatformSystemModules(ctx android.EarlyModuleContext) string {
95	if useLegacyCorePlatformApi(ctx, ctx.ModuleName()) {
96		return config.LegacyCorePlatformSystemModules
97	} else {
98		return config.StableCorePlatformSystemModules
99	}
100}
101
102func corePlatformBootclasspathLibraries(ctx android.EarlyModuleContext) []string {
103	if useLegacyCorePlatformApi(ctx, ctx.ModuleName()) {
104		return config.LegacyCorePlatformBootclasspathLibraries
105	} else {
106		return config.StableCorePlatformBootclasspathLibraries
107	}
108}
109