diff --git a/services/core/java/com/android/server/pm/dex/PackageDynamicCodeLoading.java b/services/core/java/com/android/server/pm/dex/PackageDynamicCodeLoading.java index cc26c9b5f76ca..9159851a5470d 100644 --- a/services/core/java/com/android/server/pm/dex/PackageDynamicCodeLoading.java +++ b/services/core/java/com/android/server/pm/dex/PackageDynamicCodeLoading.java @@ -538,9 +538,10 @@ private boolean add(String path, char fileType, int userId, String loadingPackag } else { if (fileInfo.mUserId != userId) { // This should be impossible: private app files are always user-specific and - // can't be accessed from different users. - throw new IllegalArgumentException("Cannot change userId for '" + path - + "' from " + fileInfo.mUserId + " to " + userId); + // can't be accessed from different users. But it does very occasionally happen + // (b/323665257). Ignore such cases - we shouldn't record data from a different + // user. + return false; } // Changing file type (i.e. loading the same file in different ways is possible if // unlikely. We allow it but ignore it. diff --git a/services/tests/servicestests/src/com/android/server/pm/dex/PackageDynamicCodeLoadingTests.java b/services/tests/servicestests/src/com/android/server/pm/dex/PackageDynamicCodeLoadingTests.java index e075379284f01..c0ea1571d8c77 100644 --- a/services/tests/servicestests/src/com/android/server/pm/dex/PackageDynamicCodeLoadingTests.java +++ b/services/tests/servicestests/src/com/android/server/pm/dex/PackageDynamicCodeLoadingTests.java @@ -106,13 +106,13 @@ public void testRecord_returnsHasChanged() { } @Test - public void testRecord_changeUserForFile_throws() { + public void testRecord_changeUserForFile_ignored() { Entry entry1 = new Entry("owning.package1", "/path/file1", 'D', 10, "loading.package1"); Entry entry2 = new Entry("owning.package1", "/path/file1", 'D', 20, "loading.package1"); PackageDynamicCodeLoading info = makePackageDcl(entry1); - assertThrows(() -> record(info, entry2)); + assertThat(record(info, entry2)).isFalse(); assertHasEntries(info, entry1); }