summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jiakai Zhang <jiakaiz@google.com> 2025-03-21 03:40:44 -0700
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2025-03-21 03:40:44 -0700
commit8e7c52277507861a3060e059f1975ad91e96aa66 (patch)
tree9b698b49ee18230a3983625f628902b545186571
parent9c8ef801f690c366b3fe8503086fd78b0e518a72 (diff)
parentdcc57092954854e5abb6a9fa21e6f13359673ee4 (diff)
Update input vdex selection logic for SDM. am: dcc5709295
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>
-rw-r--r--artd/binder/com/android/server/art/ArtifactsLocation.aidl11
-rw-r--r--libartservice/service/java/com/android/server/art/Dexopter.java5
-rw-r--r--libartservice/service/javatests/com/android/server/art/PrimaryDexopterTest.java79
3 files changed, 56 insertions, 39 deletions
diff --git a/artd/binder/com/android/server/art/ArtifactsLocation.aidl b/artd/binder/com/android/server/art/ArtifactsLocation.aidl
index 1084456dec..bb1d505c29 100644
--- a/artd/binder/com/android/server/art/ArtifactsLocation.aidl
+++ b/artd/binder/com/android/server/art/ArtifactsLocation.aidl
@@ -27,4 +27,15 @@ enum ArtifactsLocation {
NEXT_TO_DEX = 2,
/** In the dex metadata file. This means the only usable artifact is the VDEX file. */
DM = 3,
+ /**
+ * The OAT and ART files are in the SDM file next to the dex file. The VDEX file is in the DM
+ * file next to the dex file. The SDC file is in the global "dalvik-cache" folder. (This happens
+ * typically when the app is in incremental-fs.)
+ */
+ SDM_DALVIK_CACHE = 4,
+ /**
+ * The OAT and ART files are in the SDM file next to the dex file. The VDEX file is in the DM
+ * file next to the dex file. The SDC file is next to the dex file.
+ */
+ SDM_NEXT_TO_DEX = 5,
}
diff --git a/libartservice/service/java/com/android/server/art/Dexopter.java b/libartservice/service/java/com/android/server/art/Dexopter.java
index 49bba8105e..d3bcdbb270 100644
--- a/libartservice/service/java/com/android/server/art/Dexopter.java
+++ b/libartservice/service/java/com/android/server/art/Dexopter.java
@@ -628,7 +628,10 @@ public abstract class Dexopter<DexInfoType extends DetailedDexInfo> {
return VdexPath.artifactsPath(AidlUtils.buildArtifactsPathAsInput(
dexPath, isa, false /* isInDalvikCache */));
case ArtifactsLocation.DM:
- // The DM file is passed to dex2oat as a separate flag whenever it exists.
+ case ArtifactsLocation.SDM_DALVIK_CACHE:
+ case ArtifactsLocation.SDM_NEXT_TO_DEX:
+ // In these cases, the VDEX file is in the DM file. The whole DM file is passed to
+ // dex2oat as a separate flag whenever it exists.
return null;
default:
// This should never happen as the value is got from artd.
diff --git a/libartservice/service/javatests/com/android/server/art/PrimaryDexopterTest.java b/libartservice/service/javatests/com/android/server/art/PrimaryDexopterTest.java
index 0711eff49c..b032538bbb 100644
--- a/libartservice/service/javatests/com/android/server/art/PrimaryDexopterTest.java
+++ b/libartservice/service/javatests/com/android/server/art/PrimaryDexopterTest.java
@@ -63,6 +63,7 @@ import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
import java.util.zip.ZipFile;
@SmallTest
@@ -157,50 +158,52 @@ public class PrimaryDexopterTest extends PrimaryDexopterTestBase {
mUsedEmbeddedProfiles = new ArrayList<>();
}
- @Test
- public void testDexoptInputVdex() throws Exception {
- // null.
- doReturn(dexoptIsNeeded(ArtifactsLocation.NONE_OR_ERROR))
+ private void checkDexoptInputVdex(
+ @ArtifactsLocation int location, Supplier<VdexPath> inputVdexMatcher) throws Exception {
+ doReturn(dexoptIsNeeded(location))
.when(mArtd)
.getDexoptNeeded(eq(mDexPath), eq("arm64"), any(), any(), anyInt());
- doReturn(mArtdDexoptResult)
- .when(mArtd)
- .dexopt(any(), eq(mDexPath), eq("arm64"), any(), any(), any(), isNull(), any(),
- anyInt(), any(), any());
- // ArtifactsPath, isInDalvikCache=true.
- doReturn(dexoptIsNeeded(ArtifactsLocation.DALVIK_CACHE))
- .when(mArtd)
- .getDexoptNeeded(eq(mDexPath), eq("arm"), any(), any(), anyInt());
- doReturn(mArtdDexoptResult)
- .when(mArtd)
- .dexopt(any(), eq(mDexPath), eq("arm"), any(), any(), any(),
- deepEq(VdexPath.artifactsPath(AidlUtils.buildArtifactsPathAsInput(
- mDexPath, "arm", true /* isInDalvikCache */))),
- any(), anyInt(), any(), any());
+ List<DexContainerFileDexoptResult> results = mPrimaryDexopter.dexopt();
+ verifyStatusAllOk(results);
+ verify(mArtd).dexopt(any(), eq(mDexPath), eq("arm64"), any(), any(), any(),
+ inputVdexMatcher.get(), any(), anyInt(), any(), any());
+ }
- // ArtifactsPath, isInDalvikCache=false.
- doReturn(dexoptIsNeeded(ArtifactsLocation.NEXT_TO_DEX))
- .when(mArtd)
- .getDexoptNeeded(eq(mSplit0DexPath), eq("arm64"), any(), any(), anyInt());
- doReturn(mArtdDexoptResult)
- .when(mArtd)
- .dexopt(any(), eq(mSplit0DexPath), eq("arm64"), any(), any(), any(),
- deepEq(VdexPath.artifactsPath(AidlUtils.buildArtifactsPathAsInput(
- mSplit0DexPath, "arm64", false /* isInDalvikCache */))),
- any(), anyInt(), any(), any());
+ @Test
+ public void testDexoptInputVdexNoneOrError() throws Exception {
+ checkDexoptInputVdex(ArtifactsLocation.NONE_OR_ERROR, () -> isNull());
+ }
- // DexMetadataPath.
- doReturn(dexoptIsNeeded(ArtifactsLocation.DM))
- .when(mArtd)
- .getDexoptNeeded(eq(mSplit0DexPath), eq("arm"), any(), any(), anyInt());
- doReturn(mArtdDexoptResult)
- .when(mArtd)
- .dexopt(any(), eq(mSplit0DexPath), eq("arm"), any(), any(), any(), isNull(), any(),
- anyInt(), any(), any());
+ @Test
+ public void testDexoptInputVdexDalvikCache() throws Exception {
+ checkDexoptInputVdex(ArtifactsLocation.DALVIK_CACHE, () -> {
+ return deepEq(VdexPath.artifactsPath(AidlUtils.buildArtifactsPathAsInput(
+ mDexPath, "arm64", true /* isInDalvikCache */)));
+ });
+ }
- List<DexContainerFileDexoptResult> results = mPrimaryDexopter.dexopt();
- verifyStatusAllOk(results);
+ @Test
+ public void testDexoptInputVdexNextToDex() throws Exception {
+ checkDexoptInputVdex(ArtifactsLocation.NEXT_TO_DEX, () -> {
+ return deepEq(VdexPath.artifactsPath(AidlUtils.buildArtifactsPathAsInput(
+ mDexPath, "arm64", false /* isInDalvikCache */)));
+ });
+ }
+
+ @Test
+ public void testDexoptInputVdexDm() throws Exception {
+ checkDexoptInputVdex(ArtifactsLocation.DM, () -> isNull());
+ }
+
+ @Test
+ public void testDexoptInputVdexSdmDalvikCache() throws Exception {
+ checkDexoptInputVdex(ArtifactsLocation.SDM_DALVIK_CACHE, () -> isNull());
+ }
+
+ @Test
+ public void testDexoptInputVdexSdmNextToDex() throws Exception {
+ checkDexoptInputVdex(ArtifactsLocation.SDM_NEXT_TO_DEX, () -> isNull());
}
@Test