From 156c719179b0cb5fdfce900bdedc30df40ce9315 Mon Sep 17 00:00:00 2001 From: Ulya Trafimovich Date: Tue, 2 Feb 2021 12:59:08 +0000 Subject: [PATCH] Quick and dirty filtering of present LOCAL_OPTIONAL_USES_LIBRARIES. Filter LOCAL_OPTIONAL_USES_LIBRARIES by PRODUCT_PACKAGES. This has the drawback that some present libraries may be filtered out as well, as the full list of product packages is unknown until all Android.mk files have been read. This CL unblocks fixes for individual apps, which will be necessary to dexpreopt them in the nearest future when the &-classpath hack is removed in ART. Apps that are not fixed by then will loose dexpreopt completely. This fix, although not perfect, lowers the risk of loosing dexpreopt for many apps. In the future it may be replaced with a better solution. Bug: 132357300 Test: lunch aosp_cf_x86_64_phone-userdebug && m && launch_cvd \ adb wait-for-device && adb root && adb logcat \ | grep -E 'ClassLoaderContext [a-z ]+ mismatch' # empty grep output, no errors Change-Id: I188cf240259f7a448623450e6a949e0784a21f87 --- core/dex_preopt_odex_install.mk | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk index 084b302af..6f6ac2803 100644 --- a/core/dex_preopt_odex_install.mk +++ b/core/dex_preopt_odex_install.mk @@ -189,6 +189,16 @@ ifdef LOCAL_DEX_PREOPT my_filtered_optional_uses_libraries := $(filter-out $(INTERNAL_PLATFORM_MISSING_USES_LIBRARIES), \ $(LOCAL_OPTIONAL_USES_LIBRARIES)) + # TODO(b/132357300): This may filter out too much, as PRODUCT_PACKAGES doesn't + # include all packages (the full list is unknown until reading all Android.mk + # makefiles). As a consequence, a library may be present but not included in + # dexpreopt, which will result in class loader context mismatch and a failure + # to load dexpreopt code on device. We should fix this, either by deferring + # dependency computation until the full list of product packages is known, or + # by adding product-specific lists of missing libraries. + my_filtered_optional_uses_libraries := $(filter $(my_filtered_optional_uses_libraries), \ + $(PRODUCT_PACKAGES)) + ifeq ($(LOCAL_MODULE_CLASS),APPS) # compatibility libraries are added to class loader context of an app only if # targetSdkVersion in the app's manifest is lower than the given SDK version