summaryrefslogtreecommitdiff
path: root/libartservice
AgeCommit message (Collapse)Author
2025-03-21Delete SDM files on "pm delete-dexopt" and "pm compile --reset". am: d6e56a41da Jiakai Zhang
Original change: https://android-review.googlesource.com/c/platform/art/+/3545384 Change-Id: I72d7ea5cd7a7a084fe711c036e9ed4141d61cb88 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2025-03-21Delete SDM and SDC files on a successful dexopt. am: 9126e6fb21 Jiakai Zhang
Original change: https://android-review.googlesource.com/c/platform/art/+/3545383 Change-Id: I115177d643ab57b4ac3c8af27280f1feaa6ff2e0 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2025-03-21Update the file GC to clean up SDM files. am: 751ffe4a74 Jiakai Zhang
Original change: https://android-review.googlesource.com/c/platform/art/+/3545382 Change-Id: I2a1ce48baefd7cdaed2825cbc6e969a11493f6fb Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2025-03-21Count SDM files into TYPE_DEXOPT_ARTIFACT in ART-managed file stats. am: ↵ Jiakai Zhang
0f7d94bd99 Original change: https://android-review.googlesource.com/c/platform/art/+/3545381 Change-Id: Iaa9e62c175e688450429793264318bdacf671a99 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2025-03-21Delete SDM files on "pm delete-dexopt" and "pm compile --reset". Jiakai Zhang
If SDM files are installed and then cleaned up after becoming obsolete, "pm delete-dexopt" will put the app in a state where there is not dexopt artifacts to use. Therefore, for consistency in terms of app performance, we should delete SDM files on "pm delete-dexopt" even if they are not obsolete. "pm compile --reset" has a similar situation. If SDM files are installed and then cleaned up after becoming obsolete, "pm compile --reset" will put the app in a state where its dexopt artifacts are generated on device with the cloud profile (ideally, the behavior should be restoring the SDM files, but that's impossible). Therefore, for consistency in terms of app performance (assuming locally generated artifacts and cloud artifacts have different performance), we should delete SDM files and regenerate dexopt artifacts on device on "pm compile --reset". Bug: 377474232 Test: atest ArtServiceTests Change-Id: If1934b6c7da19ad346f4962241bbdab13fa12ce6
2025-03-21Delete SDM and SDC files on a successful dexopt. Jiakai Zhang
After a successful dexopt (typically during background dexopt job), the SDM and SDC files become obsolete, so we delete them as an optimization, to release disk space as soon as possible. Bug: 377474232 Test: atest ArtServiceTests Test: atest art_standalone_artd_tests Change-Id: I9598e3b6d71a2575d73885cc4d772737f9bfb2b6
2025-03-21Update the file GC to clean up SDM files. Jiakai Zhang
If the best compilation artifacts are the ones generated on device, the file GC should delete the SDM files. Bug: 377474232 Test: atest ArtServiceTests Test: atest art_standalone_artd_tests Change-Id: If2f7c31525ff9a8a03cc16fefc16a6ebcf9fad96
2025-03-21Count SDM files into TYPE_DEXOPT_ARTIFACT in ART-managed file stats. Jiakai Zhang
SDM files contain ODEX and ART files, which are dexopt artifacts. We don't need to count the DM files containing VDEX files because the storage manager counts them itself. This CL implements the extension to getUsableArtifacts to achieve this, which is also necessary for the file GC in the next CL. Also: - Fix a bug that the runtime images were not counted if the artifact location is ArtifactsLocation.DM. - Replace @AutoValue classes with records, to simplify the code. Bug: 377474232 Test: atest ArtServiceTests Test: atest art_standalone_artd_tests Change-Id: If1d05d69051d09ebd7f10e6f487cd7892590921c
2025-03-21Omit file existence check on notifyDexContainersLoaded. Jiakai Zhang
This is due to sepolicy restrictions on some platforms. Bug: 401662336 Bug: 391895923 Test: atest ArtServiceTests Test: app-debug.apk in b/391895923#comment3 Flag: EXEMPT bugfix Change-Id: Ib6d878a678ddafd02fb48d92ddfbabdfd6f4f14e
2025-03-21Update input vdex selection logic for SDM. am: dcc5709295 Jiakai Zhang
Original change: https://android-review.googlesource.com/c/platform/art/+/3545380 Change-Id: Ia680cf3f023173d5699aa007cd2a14f551e271c8 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2025-03-21Create SDC files on dexopt. am: 4383f83896 Jiakai Zhang
Original change: https://android-review.googlesource.com/c/platform/art/+/3541822 Change-Id: I3d339ba8b4098a1b84fcc54f785fdf1287d005cd Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2025-03-21Update input vdex selection logic for SDM. Jiakai Zhang
When the artifacts location is SDM_*, the vdex file is in the DM file, which is passed to dex2oat as a separate flag whenever it exists, so we don't need to pass input vdex. Bug: 377474232 Test: atest ArtServiceTests Change-Id: I07726baa04e70bc22850e2ba5ce8df44dc5b80b0
2025-03-21Create SDC files on dexopt. Jiakai Zhang
Bug: 377474232 Test: atest ArtServiceTests Change-Id: Ia7ab6937bc7b1d9e5aaad1ca57bb0a22ad3fcab2
2025-03-20Move more path logic for tests to testing.cc, so it can be used without am: ↵ Martin Stjernholm
6f3beba5e0 Original change: https://android-review.googlesource.com/c/platform/art/+/3545399 Change-Id: I3d8cf7b4b08ae07377d1c43493ca4be811c63383 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2025-03-20Move more path logic for tests to testing.cc, so it can be used without Martin Stjernholm
depending on CommonArtTest. Preparation to fix the libart-gtest dependency in art_standalone_libartpalette_tests. Due to a new #include, this necessitated fixing a bunch of `testing` namespace references that could become ambigious wrt `art::testing`. Test: m generate-boot-image Test: art/tools/buildbot-build.sh Bug: 404306250 Change-Id: Iafb3d73148125775c9c5ddbcbaef39dc61859118
2025-03-11Remove SDM status from dump. am: a6a75dba00 am: 292b4ac2ec Jiakai Zhang
Original change: https://android-review.googlesource.com/c/platform/art/+/3521810 Change-Id: I6dd1918fd6b7aa70d36356efaa6a314c3c58469d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2025-03-11Remove SDM status from dump. Jiakai Zhang
The SDM status has two fields: sdm-status and sdm-signature. sdm-status can actually be inferred from the compiler filter and the compilation reason, as SDM files should contain special compilation reasons. sdm-signature is no longer necessary after we added install-time check on SDM files, making SDM files with the wrong signature rejected. This change essentially reverts https://r.android.com/3342909. Bug: 377474232 Test: atest ArtServiceTests Change-Id: I079f21715afd4039bb801d3c8b79ec8a49b3c687
2025-03-11Fix SELinux denial on GMS Core's symlinks to secondary dex files. Jiakai Zhang
Bug: 401662336 Bug: 391895923 Test: Presubmit Flag: EXEMPT bugfix Change-Id: Iaa9a716cfe262897e313b994db92855721e1dfcc
2025-03-03Ensure the dex use database cannot grow unboundedly. Jiakai Zhang
Its size can theoretically be O(<owning package> X <dex path> X <loading package>) Owning and loading packages are limited by the valid entries in the package database. Dex paths from primary dex'es are also limited by the installed packages. However dex paths for secondary dex'es can potentially be unbounded, so impose a limit on them. The limit is fixed for any given owning package, which is simpler than limiting based on loading package. That restricts a package from adding an arbitrary number of secondary dex files in itself. Also check that the dex file exists if the loading package is different from the owning one, so that the former cannot consume entries up to the limit for the latter. The class loader context strings for secondary dex files are also not guaranteed bounded, so impose a limit on them as well. Test: atest DexUseManagerTest Test: Install app_debug.apk from b/391895923#comment3 and verify that it can run until OOM repeatedly without growing the database to more than 650 KiB. Bug: 391895923 Flag: EXEMPT bugfix Ignore-AOSP-First: Security fix Change-Id: Ic50bf22000730282d90a4f6aa1c49379357fe77a
2025-02-20Report atoms to StatsD also when DexOpt is skipped Stefano Cianciulli
Bug: 327134025 Test: atest art_standalone_artd_tests && atest ArtServiceTests Change-Id: I2b7e889628df23e6e59cbf9fafbebd8f9168d7d8
2025-02-19Avoid mocking the Process class in DexUseManagerTest. Jiakai Zhang
Process is a class on bootclasspath, so the test framework may use it as well. If we mock it, we affect the test framework, causing unexpected behaviors. Bug: 397234253 Bug: 397561164 Change-Id: I94f8b46b272374904b8ffbba46ebd30e4ea75019 Test: Presubmit
2025-02-18Implement Async Pre-reboot Dexopt using update_engine API. Jiakai Zhang
Bug: 377557749 Test: atest ArtServiceTests Change-Id: Icbb8e0eb022728f23b87822a894a0e9ceabbf20b
2025-02-18Support SDM files for multiple ISAs. Jiakai Zhang
After this change, ART Service supports multiple SDM files for a single APK, one for each ISA. SDM filenames are in the format of "<stem>.<isa>.sdm". Bug: 377474232 Test: atest -a CtsCompilationTestCases Test: atest ArtServiceTests Change-Id: I41d6915f58dc897418887ecec4861986533bd8dd
2025-02-14Clarify the exact behavior of "pm compile --reset". Jiakai Zhang
The command doesn't clear the reference profile if it's from the dm file. Change-Id: I782457cbc198b2048ff3f147898b1eefbc36e580 Test: N/A
2025-02-11DexMetadataHelper: Fix logging for missing config.pb file Stefano Cianciulli
Bug: 327134025 Change-Id: Id148e790c1e28680aa48276a829636b6aca8cfb6 Test: atest art_standalone_artd_tests && atest ArtServicesTest
2025-01-30Add ArtShellCommandTest and cover pre-reboot dexopt commands. Jiakai Zhang
Bug: 377557749 Test: atest ArtServiceTests Change-Id: Ie6d4e6699b1759d13627fe06cebd338aebddbc59
2025-01-29Move stats reporting from PreRebootDriver to PreRebootDexoptJob. Jiakai Zhang
In the async flow for OTA, we need to call an update_engine API in PreRebootDexoptJob, so we have to report stats there. Also, this CL changes where a fatal error is handled, so that a fatal error can be propagated to the shell command handler and shown to the user. Bug: 377557749 Test: atest ArtServiceTests Change-Id: I2e939b147706d4d35c4b813c37db3225871870cd
2025-01-17Use Java 17 `toList` method. Jiakai Zhang
Test: atest ArtServiceTests Change-Id: I33655cd8da459e60f2d119d801560ba61659d179
2025-01-17Flush profiles upon `pm dump-profiles`. Jiakai Zhang
Before this change, `pm dump-profiles` only dumps the profiles that are already on disk. Users can force the app to flush the profiles from the memory to the disk by sending `SIGUSR1` to app processes, but this is not ideal: 1. The shell user cannot send `SIGUSR1`, meaning it doesn't work on user builds. 2. The user doesn't know when the profile save is done, so they need to conservatively wait a long time after sending `SIGUSR1`, typically 1 second or more. After this change, `pm dump-profiles` forces the app to flush the profiles from the memory to the disk before dumping the profiles. The profile flush is implemented in the following flow: For each app process: 1. `artd` uses inotify(7) to listen to changes in `/data/misc/profiles/cur/<user_id>/<package_name>/` 2. `system_server` sends `SIGUSR1` to the app process. 3. The app process always flushes profiles upon the signal and the profile for the primary APK is always the last one to write. 4. `artd` waits for the profile for the primary APK to be written. Bug: 254102312 Test: atest ArtServiceTests Test: adb shell pm dump-profiles com.google.android.gms Change-Id: I7ea2403f2ba6aa1fcbefa0f42a9ca51487aa7ef5
2024-12-09Hide SDM status if not found. Jiakai Zhang
The SDM status looks too noisy in the bugreport, especially given that the feature is not actually being used by anyone. Bug: 377474232 Test: m Change-Id: I9e26f2d4b3f707eb5ac167052ed225533dcd8f3b
2024-12-09Mock calls to Binder in DexUseManagerLocalTest Jiakai Zhang
Bug: 382080250 Change-Id: Ic9129d5ffe85c476ffa1fa45b07c870b77fae392 Test: ABTD (http://go/abtd/run/L04000030008181623)
2024-11-27Add a dump option to dump SDM status. Jiakai Zhang
This will be used in CompilationTest in order to test SDM support. Bug: 377474232 Test: atest ArtServiceTests:DumpHelperTest Test: adb shell pm art dump --include-sdm-status <package-name> Change-Id: I1693ed0b3873e58ff4e611fba377eda42deb74b3
2024-11-26Add APIs for ART managed install files. Jiakai Zhang
Bug: 377887025 Test: atest ArtServiceTests Test: atest art_standalone_artd_tests Change-Id: I0836a0523dd80b24b0a0452efec023282237824f
2024-11-18Don't reuse the old snapshot after a long running bg dexopt to do the Martin Stjernholm
file cleanup. In particular this avoids deleting the dexopt artifacts for any new apps installed since the background dexopt started. It may still incorrectly delete files for new installs during the cleanup run, but that time window is much shorter (on the order of 5-10 secs, vs 5-20 mins for a whole background dexopt run). The dexopt and the cleanup are two independent operations, so they don't need to use the same snapshot. Test: atest ArtServiceTests Bug: 378773852 Change-Id: I75c8f5b4934fb86facdd8d31ae18aab63426a346
2024-11-11Add a comment to explain the API considerations for the pre-reboot Martin Stjernholm
dexopt usage of BatchDexoptParamsProto. Test: n/a - comment change only Bug: 356996742 Change-Id: I01f170a95aaf718891ad70efb2d0d77844840f5a
2024-11-11Consolidate the use of some constants. Jiakai Zhang
Bug: 377474232 Test: atest ArtServiceTests Test: atest art_standalone_artd_tests Test: atest art_standalone_odrefresh_tests Test: atest art_standalone_libartbase_tests Test: atest art_standalone_runtime_tests Test: atest art_standalone_dex2oat_tests Change-Id: I66a29ea85176c6c6d676537fe6e4e64152360acc
2024-11-06Allow Pre-reboot Dexopt to be configured by BatchDexoptStartCallback. Jiakai Zhang
Instead of calling `BatchDexoptStartCallback` from `ArtManagerLocal.dexoptPackages` in the new service-art.jar loaded from the OTA/Mainline package, do it in the current one where the OEM may have configured it, and send over the resulting `BatchDexoptParams` data instead. Bug: 356996742 Bug: 369233230 Test: atest ArtServiceTests Test: - 1. adb shell configure-batch-dexopt -r ab-ota --package com.android.settings --package com.android.calendar 2. adb shell pm art pr-dexopt-job --run Change-Id: I4ab65cecb4fa7724a6e1ac1a04532ac2d3fef4ef
2024-11-06Ignore `setSplitName` in `BatchDexoptStartCallback`. Jiakai Zhang
This change globally ignores `setSplitName` in `BatchDexoptStartCallback`, for all batch dexopt reasons. This is because `setSplitName` only makes sense for a single package. Bug: 356996742 Bug: 369233230 Test: Presubmit Change-Id: I172951e41dbb4bdddabc3f18a574dc53c7882551
2024-10-31Update ART Service README.md Jiakai Zhang
- Add a warning that ART Service does not perform dexopt operations on running apps. - Clarify that the background dexopt job is triggered daily. Change-Id: Ic4c4c9e3982291d80f3237b5aca6f4bbffa31351
2024-10-01Skip dexopt if storage is low during Pre-reboot Dexopt. Jiakai Zhang
Bug: 368238938 Change-Id: I532a899e8c011fed9abc16c073f1665d11de83c7 Test: Presubmit
2024-10-01Add some logging to help debug pre-reboot dexopt. Martin Stjernholm
Test: `atest ArtOtaPreRebootDexoptTest` with ag/29425344 Bug: 292998825 Change-Id: Id79cb35950e964e19a276722b0f9c26c7d15a9ab
2024-09-20Offload `PreRebootDexoptJob.onUpdateReady` to a separate thread. Jiakai Zhang
Before this change, `PreRebootDexoptJob.onUpdateReady` is called on the package manager thread during an apex installation and triggered a pre-watchdog (1/4 of the watchdog timeout). This change fixes it. Bug: 366387132 Test: atest ArtServiceTests Change-Id: Ie50c04c1bfa81d38178ed1a2aa37a766f2da8a4a
2024-09-20Report dex2oat metrics to StatsD when dexopting Stefano Cianciulli
Bug: 327134025 Test: atest art_standalone_artd_tests && atest ArtServicesTest Change-Id: I4212899e78c23d8ff8c0307f9699f6b772c50000
2024-09-10Clean up UnflaggedApi. Jiakai Zhang
Bug: 353479602 Test: m Change-Id: I6b9c456ea9ac38872ed9972d301c2bd9f870e3ae
2024-09-06Don't filter default package list for first boot dexopt Rashid Zaman
commit 20a8542b513a ("Implement app downgrading.") added filtering of the list of packages to dexopt and for REASON_FIRST_BOOT this filtered the list of packages based on last active time which is determined as the maximum of a package's last used time and first install time. During first boot a package's last used time is 0 so the last active time is based on a package's installation time which after commit cbd2f357c218 ("[pm] use actual scanning time as firstInstallTime for preload apps") in frameworks/base when fix_system_apps_first_install_time is enabled is set to the current time as returned by System.currentTimeMillis() when packages are being installed during PackageManagerService startup. This can be a problem during first boot if pm.dexopt.downgrade_after_inactive_days is set because in this case packages with a last active time (installation time in this case) more than pm.dexopt.downgrade_after_inactive_days in the past will be be filtered out of the default package list and not dexopted and this filtering is done relative to the current time as returned by System.currentTimeMillis() which in some cases will have been advanced by AlarmManagerService after package installation to the build time as set in ro.build.date.utc. This can happen on some devices, for example, when the RTC has never been set correctly or is set to a time more than pm.dexopt.downgrade_after_inactive_days prior to the build time in ro.build.date.utc as kernels with CONFIG_RTC_HCTOSYS enabled will set the system time using the value read from the RTC during kernel init and this will be the time used to set the first install time for packages and will later cause AlarmManagerService to advance the system time prior to first boot dexopt. Fix these cases as well by not doing any filtering for first boot dexopt. Test: Set pm.dexopt.downgrade_after_inactive_days=10 on aosp_cheetah-trunk_staging-userdebug and set system time to more than 10 days in the past and confirm with debugger and ART Service logging that there are now packages being dexopted: adb shell 'date @1723857773' && adb shell hwclock -w && adb reboot bootloader && fastboot flashall -w Test: atest ArtServiceTests Change-Id: I4ebd74766cfe21db4001b44bd292cc042a8e23f0
2024-08-23Add a fallback to bind-mount external libs elsewhere during Pre-reboot. Jiakai Zhang
On Android V release (AP3A), we cannot bind-mount /system{,_ext}/lib{,64} due to lack of an SELinux permission. As a workaround, we bind-mount external libs at /mnt/compat_env/system{,_ext}/lib{,64}, and patch the linker config to make artd and art_exec link against external libs from there. This change bumps the Pre-reboot version to 3, as the incompatibility issue in Pre-reboot Dexopt is fully fixed after this change. Note: 1. Only artd and art_exec needs to link against old external libs so far. artd depends on libbinder_ndk.so, and art_exec depends on libcgrouprc.so, where incompatibilities with the platform can occur. Forrunately, both of them have the "search" permission on /mnt/compat_env, where the bind-mounted old libs locate at. 2. When this fallback is used, other binaries such as dex2oat still link against new external libs because they don't have the "search" permission on /mnt/compat_env. Forrunately, they don't have to link against old libs. Bug: 356858364 Test: atest art_standalone_dexopt_chroot_setup_tests Test: - 1. Flash AP3A.241005.002. 2. Build an ART apex with this CL and install it. 3. adb shell setprop ro.ota.allow_downgrade true 4. OTA to AP4A.240729.001 (the bad OTA package that has https://r.android.com/3194614, which introduced an incompatibility with AP3A build, but does not have https://r.android.com/3196705, which disabled Pre-reboot Dexopt). Change-Id: I9505b60d4cc47965bb08f06ed23c6c0b47906700
2024-08-22Optimize DexUseManagerLocal.findOwningPackage - Step 2. Jiakai Zhang
This CL adds an early return for shared libraries, which is not supposed to be a semantic change, though it's not obvious that's the case. Bug: 328673771 Test: atest ArtServiceTests Change-Id: Idc6647d5fd78e3af0f642c7e3a08d993e4ea18eb
2024-08-20Revert^2 "Remove ART Service tests from chroot tests." Jiakai Zhang
This reverts commit 73a49cd990a10d7e21d41be001170e72e6ba3d49. Reason for revert: Problem fixed For target tests that are included in the ART testing apex, Soong generates Make modules to build them for the apex. After removing target tests from the ART testing apex, Soong starts to generate Make modules to build them at $ANDROID_PRODUCT_OUT/testcases, and art-host-tests.mk unexpectedly picks them up from there and packs them into art-host-tests.zip. Adding `device_supported: false` solves the problem. A follow up change will be made to stop art-host-tests.mk from packing target tests into art-host-tests.zip. Bug: 357802879 Bug: 356793689 Bug: 360150490 Test: art/test/README.chroot.md Change-Id: I05adfbc6ea633640a040cfdc0527effa6ef01cab
2024-07-29Clean up the mounts for Pre-reboot Dexopt on system_server restart. Jiakai Zhang
When there is a system_server restart, it's possible that a previous Pre-reboot Dexopt job didn't end normally and left over a chroot, so we need to clean it up, or we may potentially block update_engine (if there is an OTA). Bug: 354140992 Test: Run Pre-reboot Dexopt and then kill system_server. Change-Id: Ieb5ee411d136224e4f1bb50cb1389d2472d27143
2024-07-23Optimize DexUseManagerLocal.findOwningPackage - Step 1. Jiakai Zhang
This CLs contains no semantic change. Optimizations are: 1. Using UnfilteredSnapshot to defer the shouldFilterApplication check 2. Check if the dex is secondary dex of the loading package before checking if it's primary dex of other packages 3. Adding an LRU cache for recent packages Bug: 328673771 Test: atest ArtServiceTests Change-Id: I7974b0240a81e6a62ad15a6cb5825a6278ce05d1