From d5fe8782e089ec1539a133f270aa62f5d3ead61a Mon Sep 17 00:00:00 2001 From: Jeongik Cha Date: Thu, 8 Jul 2021 01:13:11 +0900 Subject: SdkLibraryImport's DexJarInstallPath uses installPath from source module Even though actual installed module path is the same as source module, it uses impl's one. Bug: 188179858 Bug: 193082464 Test: compare dexpreopt_config.zip files from 1. TARGET_BUILD_UNBUNDLED_IMAGE=true m dexpreopt_config_zip 2. m dexpreopt_config_zip (note that m clean should run between steps) Test: build aosp_cf_x86_64_phone, launch_cvd, and then adb wait-for-device \ && adb root \ && adb logcat \ | grep -E 'ClassLoaderContext [a-z ]+ mismatch' -C 1 and then check if there is no message. Change-Id: I34ffd9a2d214a6614c2befc35b2beec003cfcd25 --- java/sdk_library.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'java/sdk_library.go') diff --git a/java/sdk_library.go b/java/sdk_library.go index ed9aeffd4..2b7185759 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1923,8 +1923,12 @@ type SdkLibraryImport struct { // Is nil if the source module does not exist. xmlPermissionsFileModule *sdkLibraryXml - // Path to the dex implementation jar obtained from the prebuilt_apex, if any. + // Build path to the dex implementation jar obtained from the prebuilt_apex, if any. dexJarFile android.Path + + // Expected install file path of the source module(sdk_library) + // or dex implementation jar obtained from the prebuilt_apex, if any. + installFile android.Path } var _ SdkLibraryDependency = (*SdkLibraryImport)(nil) @@ -2136,6 +2140,9 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo var deapexerModule android.Module + // Assume that source module(sdk_library) is installed in //framework + module.installFile = android.PathForModuleInstall(ctx, "framework", module.Stem()+".jar") + // Record the paths to the prebuilt stubs library and stubs source. ctx.VisitDirectDeps(func(to android.Module) { tag := ctx.OtherModuleDependencyTag(to) @@ -2195,6 +2202,7 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo) if dexOutputPath := di.PrebuiltExportPath(apexRootRelativePathToJavaLib(module.BaseModuleName())); dexOutputPath != nil { module.dexJarFile = dexOutputPath + module.installFile = android.PathForModuleInPartitionInstall(ctx, "apex", ai.ApexVariationName, apexRootRelativePathToJavaLib(module.BaseModuleName())) module.initHiddenAPI(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0], nil) } else { // This should never happen as a variant for a prebuilt_apex is only created if the @@ -2249,11 +2257,7 @@ func (module *SdkLibraryImport) DexJarBuildPath() android.Path { // to satisfy UsesLibraryDependency interface func (module *SdkLibraryImport) DexJarInstallPath() android.Path { - if module.implLibraryModule == nil { - return nil - } else { - return module.implLibraryModule.DexJarInstallPath() - } + return module.installFile } // to satisfy UsesLibraryDependency interface -- cgit v1.2.3-59-g8ed1b