Skip to content
Snippets Groups Projects
Commit d5e93616 authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Remove mini-keyctl usage from UpdatableSystemFontTest

Bug: 313005703
Test: atest UpdatableFontDirTest UpdatableSystemFontTest
Test: atest GtsFontHostTestCases FontManagerTest
Change-Id: Ib4a32a9bbb27ebd2e9a32dc308f79ec1c91332ce
parent 9de275a2
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment