legacy_core_platform_api_usage.go 3.0 KB

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