From 85ecae59b16d613426cdbee8ae592bed009f701a Mon Sep 17 00:00:00 2001 From: "Torne (Richard Coles)" Date: Tue, 30 Jan 2018 18:13:00 -0500 Subject: [PATCH] Don't attempt to preload fonts in isolated processes. Isolated processes used to run external services have the package name of the application which caused them to be started (i.e. the client application bound to the service) in their ApplicationInfo's packageName field, not the package name which is actually loaded in the current process. This meant that the font preloading code used the manifest of the client application to determine the resource ID for the preloaded font list, but then looked up that resource ID in the service's APK, which typically results in a crash as that resource ID is unlikely to exist. Avoid this case occurring by not doing font preloading in isolated processes, which are not normally capable of displaying UI in any case and so likely do not require it. Bug: 70968451 Test: CtsWebkitTestCases Change-Id: Id47e01aab28a6fd48f5928ce33d5060fb2717527 --- core/java/android/app/ActivityThread.java | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 29e091b0f26b7..5ddc03d783061 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -5874,21 +5874,23 @@ public final class ActivityThread extends ClientTransactionHandler { // Preload fonts resources FontsContract.setApplicationContextForResources(appContext); - try { - final ApplicationInfo info = - getPackageManager().getApplicationInfo( - data.appInfo.packageName, - PackageManager.GET_META_DATA /*flags*/, - UserHandle.myUserId()); - if (info.metaData != null) { - final int preloadedFontsResource = info.metaData.getInt( - ApplicationInfo.METADATA_PRELOADED_FONTS, 0); - if (preloadedFontsResource != 0) { - data.info.getResources().preloadFonts(preloadedFontsResource); + if (!Process.isIsolated()) { + try { + final ApplicationInfo info = + getPackageManager().getApplicationInfo( + data.appInfo.packageName, + PackageManager.GET_META_DATA /*flags*/, + UserHandle.myUserId()); + if (info.metaData != null) { + final int preloadedFontsResource = info.metaData.getInt( + ApplicationInfo.METADATA_PRELOADED_FONTS, 0); + if (preloadedFontsResource != 0) { + data.info.getResources().preloadFonts(preloadedFontsResource); + } } + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); } }