Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6d5685c8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix update failure if font family was installed and upgraded to 14" into 24D1-dev

parents 799b1496 54792987
Loading
Loading
Loading
Loading
+37 −5
Original line number Diff line number Diff line
@@ -196,8 +196,7 @@ final class UpdatableFontDir {
                File signatureFile = new File(dir, FONT_SIGNATURE_FILE);
                if (!signatureFile.exists()) {
                    Slog.i(TAG, "The signature file is missing.");
                    FileUtils.deleteContentsAndDir(dir);
                    continue;
                    return;
                }
                byte[] signature;
                try {
@@ -222,10 +221,36 @@ final class UpdatableFontDir {

                FontFileInfo fontFileInfo = validateFontFile(fontFile, signature);
                if (fontConfig == null) {
                    fontConfig = getSystemFontConfig();
                    // Use preinstalled font config for checking revision number.
                    fontConfig = mConfigSupplier.apply(Collections.emptyMap());
                }
                addFileToMapIfSameOrNewer(fontFileInfo, fontConfig, true /* deleteOldFile */);
            }

            // Treat as error if post script name of font family was not installed.
            for (int i = 0; i < config.fontFamilies.size(); ++i) {
                FontUpdateRequest.Family family = config.fontFamilies.get(i);
                for (int j = 0; j < family.getFonts().size(); ++j) {
                    FontUpdateRequest.Font font = family.getFonts().get(j);
                    if (mFontFileInfoMap.containsKey(font.getPostScriptName())) {
                        continue;
                    }

                    if (fontConfig == null) {
                        fontConfig = mConfigSupplier.apply(Collections.emptyMap());
                    }

                    if (getFontByPostScriptName(font.getPostScriptName(), fontConfig) != null) {
                        continue;
                    }

                    Slog.e(TAG, "Unknown font that has PostScript name "
                            + font.getPostScriptName() + " is requested in FontFamily "
                            + family.getName());
                    return;
                }
            }

            success = true;
        } catch (Throwable t) {
            // If something happened during loading system fonts, clear all contents in finally
@@ -237,6 +262,7 @@ final class UpdatableFontDir {
                mFontFileInfoMap.clear();
                mLastModifiedMillis = 0;
                FileUtils.deleteContents(mFilesDir);
                mConfigFile.delete();
            }
        }
    }
@@ -485,8 +511,7 @@ final class UpdatableFontDir {
        return shouldAddToMap;
    }

    private long getPreinstalledFontRevision(FontFileInfo info, FontConfig fontConfig) {
        String psName = info.getPostScriptName();
    private FontConfig.Font getFontByPostScriptName(String psName, FontConfig fontConfig) {
        FontConfig.Font targetFont = null;
        for (int i = 0; i < fontConfig.getFontFamilies().size(); i++) {
            FontConfig.FontFamily family = fontConfig.getFontFamilies().get(i);
@@ -511,6 +536,13 @@ final class UpdatableFontDir {
                }
            }
        }
        return targetFont;
    }

    private long getPreinstalledFontRevision(FontFileInfo info, FontConfig fontConfig) {
        String psName = info.getPostScriptName();
        FontConfig.Font targetFont = getFontByPostScriptName(psName, fontConfig);

        if (targetFont == null) {
            return -1;
        }
+557 −0

File changed.

Preview size limit exceeded, changes collapsed.