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

Commit 3930d9a3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Remove mini-keyctl usage from UpdatableSystemFontTest" into main am: 836300c3

parents bb84af4f 836300c3
Loading
Loading
Loading
Loading
+2 −15
Original line number Diff line number Diff line
@@ -130,14 +130,13 @@ public class UpdatableSystemFontTest {
    private static final Pattern PATTERN_SYSTEM_FONT_FILES =
            Pattern.compile("^/(system|product)/fonts/");

    private String mKeyId;
    private FontManager mFontManager;
    private UiDevice mUiDevice;

    @Before
    public void setUp() throws Exception {
        Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
        mKeyId = insertCert(CERT_PATH);
        insertCert(CERT_PATH);
        mFontManager = context.getSystemService(FontManager.class);
        expectCommandToSucceed("cmd font clear");
        mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
@@ -147,9 +146,6 @@ public class UpdatableSystemFontTest {
    public void tearDown() throws Exception {
        // Ignore errors because this may fail if updatable system font is not enabled.
        runShellCommand("cmd font clear", null);
        if (mKeyId != null) {
            expectCommandToSucceed("mini-keyctl unlink " + mKeyId + " .fs-verity");
        }
    }

    @Test
@@ -369,20 +365,11 @@ public class UpdatableSystemFontTest {
        assertThat(isFileOpenedBy(fontPath, EMOJI_RENDERING_TEST_APP_ID)).isFalse();
    }

    private static String insertCert(String certPath) throws Exception {
        Pair<String, String> result;
        try (InputStream is = new FileInputStream(certPath)) {
            result = runShellCommand("mini-keyctl padd asymmetric fsv_test .fs-verity", is);
        }
    private static void insertCert(String certPath) throws Exception {
        // /data/local/tmp is not readable by system server. Copy a cert file to /data/fonts
        final String copiedCert = "/data/fonts/debug_cert.der";
        runShellCommand("cp " + certPath + " " + copiedCert, null);
        runShellCommand("cmd font install-debug-cert " + copiedCert, null);
        // Assert that there are no errors.
        assertThat(result.second).isEmpty();
        String keyId = result.first.trim();
        assertThat(keyId).matches("^\\d+$");
        return keyId;
    }

    private int updateFontFile(String fontPath, String signaturePath) throws IOException {