From 2a0cc2c3a2969f10e936b9ce5d4bc066806b6366 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Mon, 16 Jan 2023 23:28:58 +0000 Subject: [PATCH] Skip rmdex when ART Service is in use. There's no suitable API that can delete optimized artifacts relative to an arbitrary APK path, so we'll rely on the ART Service file GC instead. This means some regression as stale artifacts get deleted a bit later than before. Test: atest CtsCompilationTestCases Bug: 251903639 Change-Id: Iae7ebbd891fbe58e40539ba34077320093e52924 --- .../server/pm/RemovePackageHelper.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/pm/RemovePackageHelper.java b/services/core/java/com/android/server/pm/RemovePackageHelper.java index e5aaddbf57f82..10673c6f2dd24 100644 --- a/services/core/java/com/android/server/pm/RemovePackageHelper.java +++ b/services/core/java/com/android/server/pm/RemovePackageHelper.java @@ -422,15 +422,18 @@ final class RemovePackageHelper { if (instructionSets == null) { throw new IllegalStateException("instructionSet == null"); } - String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets); - for (String codePath : allCodePaths) { - for (String dexCodeInstructionSet : dexCodeInstructionSets) { - // TODO(b/251903639): Call into ART Service. - try { - mPm.mInstaller.rmdex(codePath, dexCodeInstructionSet); - } catch (LegacyDexoptDisabledException e) { - throw new RuntimeException(e); - } catch (Installer.InstallerException ignored) { + // TODO(b/265813358): ART Service currently doesn't support deleting optimized artifacts + // relative to an arbitrary APK path. Skip this and rely on its file GC instead. + if (!DexOptHelper.useArtService()) { + String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets); + for (String codePath : allCodePaths) { + for (String dexCodeInstructionSet : dexCodeInstructionSets) { + try { + mPm.mInstaller.rmdex(codePath, dexCodeInstructionSet); + } catch (LegacyDexoptDisabledException e) { + throw new RuntimeException(e); + } catch (Installer.InstallerException ignored) { + } } } }