Loading services/core/java/com/android/server/graphics/fonts/FontManagerService.java +29 −12 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import com.android.internal.security.VerityUtils; import com.android.internal.util.DumpUtils; import com.android.internal.util.Preconditions; import com.android.server.LocalServices; import com.android.server.SystemServerInitThreadPool; import com.android.server.SystemService; import java.io.File; Loading @@ -61,6 +62,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.CompletableFuture; /** A service for managing system fonts. */ public final class FontManagerService extends IFontManager.Stub { Loading Loading @@ -136,10 +138,11 @@ public final class FontManagerService extends IFontManager.Stub { /** Class to manage FontManagerService's lifecycle. */ public static final class Lifecycle extends SystemService { private final FontManagerService mService; private final CompletableFuture<Void> mServiceStarted = new CompletableFuture<>(); public Lifecycle(@NonNull Context context, boolean safeMode) { super(context); mService = new FontManagerService(context, safeMode); mService = new FontManagerService(context, safeMode, mServiceStarted); } @Override Loading @@ -152,11 +155,20 @@ public final class FontManagerService extends IFontManager.Stub { if (!Typeface.ENABLE_LAZY_TYPEFACE_INITIALIZATION) { return null; } mServiceStarted.join(); return mService.getCurrentFontMap(); } }); publishBinderService(Context.FONT_SERVICE, mService); } @Override public void onBootPhase(int phase) { if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY) { // Wait for FontManagerService to start since it will be needed after this point. mServiceStarted.join(); } } } private static class FsverityUtilImpl implements UpdatableFontDir.FsverityUtil { Loading Loading @@ -219,13 +231,16 @@ public final class FontManagerService extends IFontManager.Stub { @Nullable private SharedMemory mSerializedFontMap = null; private FontManagerService(Context context, boolean safeMode) { private FontManagerService( Context context, boolean safeMode, CompletableFuture<Void> serviceStarted) { if (safeMode) { Slog.i(TAG, "Entering safe mode. Deleting all font updates."); UpdatableFontDir.deleteAllFiles(new File(FONT_FILES_DIR), new File(CONFIG_XML_FILE)); } mContext = context; mIsSafeMode = safeMode; SystemServerInitThreadPool.submit(() -> { initialize(); // Set system font map only if there is updatable font directory. Loading @@ -238,6 +253,8 @@ public final class FontManagerService extends IFontManager.Stub { Slog.w(TAG, "Failed to set system font map of system_server"); } } serviceStarted.complete(null); }, "FontManagerService_create"); } @Nullable Loading Loading
services/core/java/com/android/server/graphics/fonts/FontManagerService.java +29 −12 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import com.android.internal.security.VerityUtils; import com.android.internal.util.DumpUtils; import com.android.internal.util.Preconditions; import com.android.server.LocalServices; import com.android.server.SystemServerInitThreadPool; import com.android.server.SystemService; import java.io.File; Loading @@ -61,6 +62,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.CompletableFuture; /** A service for managing system fonts. */ public final class FontManagerService extends IFontManager.Stub { Loading Loading @@ -136,10 +138,11 @@ public final class FontManagerService extends IFontManager.Stub { /** Class to manage FontManagerService's lifecycle. */ public static final class Lifecycle extends SystemService { private final FontManagerService mService; private final CompletableFuture<Void> mServiceStarted = new CompletableFuture<>(); public Lifecycle(@NonNull Context context, boolean safeMode) { super(context); mService = new FontManagerService(context, safeMode); mService = new FontManagerService(context, safeMode, mServiceStarted); } @Override Loading @@ -152,11 +155,20 @@ public final class FontManagerService extends IFontManager.Stub { if (!Typeface.ENABLE_LAZY_TYPEFACE_INITIALIZATION) { return null; } mServiceStarted.join(); return mService.getCurrentFontMap(); } }); publishBinderService(Context.FONT_SERVICE, mService); } @Override public void onBootPhase(int phase) { if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY) { // Wait for FontManagerService to start since it will be needed after this point. mServiceStarted.join(); } } } private static class FsverityUtilImpl implements UpdatableFontDir.FsverityUtil { Loading Loading @@ -219,13 +231,16 @@ public final class FontManagerService extends IFontManager.Stub { @Nullable private SharedMemory mSerializedFontMap = null; private FontManagerService(Context context, boolean safeMode) { private FontManagerService( Context context, boolean safeMode, CompletableFuture<Void> serviceStarted) { if (safeMode) { Slog.i(TAG, "Entering safe mode. Deleting all font updates."); UpdatableFontDir.deleteAllFiles(new File(FONT_FILES_DIR), new File(CONFIG_XML_FILE)); } mContext = context; mIsSafeMode = safeMode; SystemServerInitThreadPool.submit(() -> { initialize(); // Set system font map only if there is updatable font directory. Loading @@ -238,6 +253,8 @@ public final class FontManagerService extends IFontManager.Stub { Slog.w(TAG, "Failed to set system font map of system_server"); } } serviceStarted.complete(null); }, "FontManagerService_create"); } @Nullable Loading