From 90b6f0492030901ff948baf394c1eee358553126 Mon Sep 17 00:00:00 2001 From: Yeabkal Wubshit Date: Fri, 7 Jul 2023 03:36:40 +0000 Subject: [PATCH] Avoid loading system font map twice. In ag/23835644, pre-installed system font maps are loaded if mUpdatableFontDir==null, so there's no need to set system font map again at the end of the constructor. Bug: 290301535 Test: presubmit Change-Id: I820e8433e309e2a706f9f32798a1b0c79b36c8ee --- .../server/graphics/fonts/FontManagerService.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/graphics/fonts/FontManagerService.java b/services/core/java/com/android/server/graphics/fonts/FontManagerService.java index d3371b1870746..080b947f44d64 100644 --- a/services/core/java/com/android/server/graphics/fonts/FontManagerService.java +++ b/services/core/java/com/android/server/graphics/fonts/FontManagerService.java @@ -228,10 +228,15 @@ public final class FontManagerService extends IFontManager.Stub { mIsSafeMode = safeMode; initialize(); - try { - Typeface.setSystemFontMap(getCurrentFontMap()); - } catch (IOException | ErrnoException e) { - Slog.w(TAG, "Failed to set system font map of system_server"); + // Set system font map only if there is updatable font directory. + // If there is no updatable font directory, `initialize` will have already loaded the + // system font map, so there's no need to set the system font map again here. + if (mUpdatableFontDir != null) { + try { + Typeface.setSystemFontMap(getCurrentFontMap()); + } catch (IOException | ErrnoException e) { + Slog.w(TAG, "Failed to set system font map of system_server"); + } } }