Merge "[DexManager] Fix off-by-N error in DexManager when reporting dex loads"

This commit is contained in:
Calin Juravle
2020-01-16 03:14:05 +00:00
committed by Gerrit Code Review
2 changed files with 26 additions and 0 deletions

View File

@@ -229,6 +229,7 @@ public class DexManager {
// If the dex file is the primary apk (or a split) and not isUsedByOtherApps
// do not record it. This case does not bring any new usable information
// and can be safely skipped.
dexPathIndex++;
continue;
}

View File

@@ -159,6 +159,31 @@ public class DexManagerTests {
assertHasDclInfo(mFooUser0, mFooUser0, fooSecondaries);
}
@Test
public void testNotifyPrimaryAndSecondary() {
List<String> dexFiles = mFooUser0.getBaseAndSplitDexPaths();
List<String> secondaries = mFooUser0.getSecondaryDexPaths();
int baseAndSplitCount = dexFiles.size();
dexFiles.addAll(secondaries);
notifyDexLoad(mFooUser0, dexFiles, mUser0);
PackageUseInfo pui = getPackageUseInfo(mFooUser0);
assertIsUsedByOtherApps(mFooUser0, pui, false);
assertEquals(secondaries.size(), pui.getDexUseInfoMap().size());
String[] allExpectedContexts = DexoptUtils.processContextForDexLoad(
Arrays.asList(mFooUser0.mClassLoader),
Arrays.asList(String.join(File.pathSeparator, dexFiles)));
String[] secondaryExpectedContexts = Arrays.copyOfRange(allExpectedContexts,
baseAndSplitCount, dexFiles.size());
assertSecondaryUse(mFooUser0, pui, secondaries, /*isUsedByOtherApps*/false, mUser0,
secondaryExpectedContexts);
assertHasDclInfo(mFooUser0, mFooUser0, secondaries);
}
@Test
public void testNotifySecondaryForeign() {
// Foo loads bar secondary files.