This change disallows Java modules in the vendor partition to use System SDK that is newer than API level 34; 34 is the latest allowed. Background 1: with Trunk Stable, the system/vendor interface is released at Q2 whereas the system/app interface is released at Q3. In other words, at Q2, the APIs which will be added to the system SDK at Q3 are not available. Since the system/vendor interface (which is fronzen at Q2) is what the modules in the vendor partition will be building against, they can't and shouldn't use those new APIs that will be added in the future (Q3). Using those APIs is risky because there's a chance that those APIs get removed or changed between Q2 and Q3. For example, 2024 Q2 is technically still Android U, not Android V. Background 2: The use of Java APIs in the vendor partition had many issues. Most significantly, those "vendor" Java apps are categorized as part of the system partition because all Java app processes require access to platform internal libraries that are prohibited to vendor processes. Furthermore, since the Project Treble, the vendor partition was re-purposed to a partition to host SoC-dependent bits - usually HALs. Implementing HALs in Java has never been officially supported and has had many loop holes. We'd like to use both background 1 and 2 as a chance to disallow any Java code in the vendor partition. However, since there are already some Java modules in the partition, we can't suddenly ban it. The deprecation will be made gradually, and this CL is the start. Note that sdk_version: "current" or "system_current" is automatically overridden into 34 or system_34. This is to prevent sudden breakage of vendor modules that have been targetting the latest (i.e. current) API level. They will however fail if they use APIs newer than API level 34. Bug: 314011075 Test: m blueprint_tests Change-Id: I59f5ac15ce9ac2ff7cc89e9c110169359077c37c
67 lines
2.2 KiB
Go
67 lines
2.2 KiB
Go
// Copyright 2024 Google Inc. All rights reserved.
|
|
//
|
|
// 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.
|
|
|
|
package java
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"android/soong/android"
|
|
)
|
|
|
|
func stringPtr(v string) *string {
|
|
return &v
|
|
}
|
|
|
|
func TestSystemSdkFromVendor(t *testing.T) {
|
|
fixtures := android.GroupFixturePreparers(
|
|
PrepareForTestWithJavaDefaultModules,
|
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
variables.Platform_sdk_version = intPtr(34)
|
|
variables.Platform_sdk_codename = stringPtr("VanillaIceCream")
|
|
variables.Platform_version_active_codenames = []string{"VanillaIceCream"}
|
|
variables.Platform_systemsdk_versions = []string{"33", "34", "VanillaIceCream"}
|
|
variables.DeviceSystemSdkVersions = []string{"VanillaIceCream"}
|
|
}),
|
|
FixtureWithPrebuiltApis(map[string][]string{
|
|
"33": {},
|
|
"34": {},
|
|
"35": {},
|
|
}),
|
|
)
|
|
|
|
fixtures.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("incompatible sdk version")).
|
|
RunTestWithBp(t, `
|
|
android_app {
|
|
name: "foo",
|
|
srcs: ["a.java"],
|
|
vendor: true,
|
|
sdk_version: "system_35",
|
|
}`)
|
|
|
|
result := fixtures.RunTestWithBp(t, `
|
|
android_app {
|
|
name: "foo",
|
|
srcs: ["a.java"],
|
|
vendor: true,
|
|
sdk_version: "system_current",
|
|
}`)
|
|
fooModule := result.ModuleForTests("foo", "android_common")
|
|
fooClasspath := fooModule.Rule("javac").Args["classpath"]
|
|
|
|
android.AssertStringDoesContain(t, "foo classpath", fooClasspath, "prebuilts/sdk/34/system/android.jar")
|
|
android.AssertStringDoesNotContain(t, "foo classpath", fooClasspath, "prebuilts/sdk/35/system/android.jar")
|
|
android.AssertStringDoesNotContain(t, "foo classpath", fooClasspath, "prebuilts/sdk/current/system/android.jar")
|
|
}
|