diff --git a/java/java.go b/java/java.go index bc58df3ad..277cdafd9 100644 --- a/java/java.go +++ b/java/java.go @@ -387,24 +387,29 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep { } } - toFile := func(v string) sdkDep { - isCore := strings.HasPrefix(v, "core_") - if isCore { - v = strings.TrimPrefix(v, "core_") + toPrebuilt := func(sdk string) sdkDep { + var api, v string + if strings.Contains(sdk, "_") { + t := strings.Split(sdk, "_") + api = t[0] + v = t[1] + } else { + api = "public" + v = sdk } - dir := filepath.Join("prebuilts/sdk", v) + dir := filepath.Join("prebuilts", "sdk", v, api) jar := filepath.Join(dir, "android.jar") - if isCore { - jar = filepath.Join(dir, "core.jar") - } - aidl := filepath.Join(dir, "framework.aidl") + // There's no aidl for other SDKs yet. + // TODO(77525052): Add aidl files for other SDKs too. + public_dir := filepath.Join("prebuilts", "sdk", v, "public") + aidl := filepath.Join(public_dir, "framework.aidl") jarPath := android.ExistentPathForSource(ctx, jar) aidlPath := android.ExistentPathForSource(ctx, aidl) if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() { return sdkDep{ invalidVersion: true, - module: "sdk_v" + v, + module: fmt.Sprintf("sdk_%s_%s_android", api, v), } } @@ -439,7 +444,7 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep { } if ctx.Config().UnbundledBuild() && v != "" { - return toFile(v) + return toPrebuilt(v) } switch v { @@ -457,7 +462,7 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep { case "core_current": return toModule("core.current.stubs", "") default: - return toFile(v) + return toPrebuilt(v) } } diff --git a/java/java_test.go b/java/java_test.go index 0e7bb18b2..65db68d5e 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -151,17 +151,14 @@ func testContext(config android.Config, bp string, "java-fg/b.java": nil, "java-fg/c.java": nil, - "prebuilts/sdk/14/android.jar": nil, - "prebuilts/sdk/14/framework.aidl": nil, - "prebuilts/sdk/current/android.jar": nil, - "prebuilts/sdk/current/framework.aidl": nil, - "prebuilts/sdk/current/core.jar": nil, - "prebuilts/sdk/system_current/android.jar": nil, - "prebuilts/sdk/system_current/framework.aidl": nil, - "prebuilts/sdk/system_14/android.jar": nil, - "prebuilts/sdk/system_14/framework.aidl": nil, - "prebuilts/sdk/test_current/android.jar": nil, - "prebuilts/sdk/test_current/framework.aidl": nil, + "prebuilts/sdk/14/public/android.jar": nil, + "prebuilts/sdk/14/public/framework.aidl": nil, + "prebuilts/sdk/14/system/android.jar": nil, + "prebuilts/sdk/current/public/android.jar": nil, + "prebuilts/sdk/current/public/framework.aidl": nil, + "prebuilts/sdk/current/public/core.jar": nil, + "prebuilts/sdk/current/system/android.jar": nil, + "prebuilts/sdk/current/test/android.jar": nil, // For framework-res, which is an implicit dependency for framework "AndroidManifest.xml": nil, @@ -340,7 +337,7 @@ var classpathTestcases = []struct { properties: `sdk_version: "14",`, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath - classpath: []string{"prebuilts/sdk/14/android.jar"}, + classpath: []string{"prebuilts/sdk/14/public/android.jar"}, }, { @@ -362,7 +359,7 @@ var classpathTestcases = []struct { properties: `sdk_version: "system_14",`, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath - classpath: []string{"prebuilts/sdk/system_14/android.jar"}, + classpath: []string{"prebuilts/sdk/14/system/android.jar"}, }, { @@ -864,9 +861,9 @@ func TestTurbine(t *testing.T) { if len(barTurbineCombined.Inputs) != 2 || barTurbineCombined.Inputs[1].String() != fooHeaderJar { t.Errorf("bar turbine combineJar inputs %v does not contain %q", barTurbineCombined.Inputs, fooHeaderJar) } - if !strings.Contains(bazJavac.Args["classpath"], "prebuilts/sdk/14/android.jar") { + if !strings.Contains(bazJavac.Args["classpath"], "prebuilts/sdk/14/public/android.jar") { t.Errorf("baz javac classpath %v does not contain %q", bazJavac.Args["classpath"], - "prebuilts/sdk/14/android.jar") + "prebuilts/sdk/14/public/android.jar") } }