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

Commit bc718220 authored by Kohsuke Yatoh's avatar Kohsuke Yatoh
Browse files

Integration test for updatable system font.

This test:
(1) signs a font file with the test key.
(2) side-loads the test cert to the device under test.
(3) verifies that the signed font file can be installed.

The device must be rootable for doing step (2).

Bug: 176939176
Test: atest UpdatableSystemFontTest
Change-Id: I7a9b614aa3c77589c3495b663cb76056ba657006
parent ad685084
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1294,6 +1294,18 @@ python_binary_host {
    ],
}

python_binary_host {
    name: "update_font_metadata",
    defaults: ["base_default"],
    main: "tools/fonts/update_font_metadata.py",
    srcs: [
        "tools/fonts/update_font_metadata.py",
    ],
    libs: [
        "fontTools",
    ],
}

filegroup {
    name: "framework-media-annotation-srcs",
    srcs: [
+2 −1
Original line number Diff line number Diff line
@@ -169,8 +169,9 @@ public class FontManagerShellCommand extends ShellCommand {
            sb.append(c++);
            sb.append("]: lang=\"");
            sb.append(family.getLocaleList().toLanguageTags());
            sb.append("\"");
            if (family.getVariant() != FontConfig.FontFamily.VARIANT_DEFAULT) {
                sb.append("\", variant=");
                sb.append(", variant=");
                switch (family.getVariant()) {
                    case FontConfig.FontFamily.VARIANT_COMPACT:
                        sb.append("Compact");
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ java_test_host {
    name: "ApkVerityTest",
    srcs: ["src/**/*.java"],
    libs: ["tradefed", "compatibility-tradefed", "compatibility-host-util"],
    static_libs: ["frameworks-base-hostutils"],
    test_suites: ["general-tests", "vts"],
    target_required: [
        "block_device_writer_module",
+6 −20
Original line number Diff line number Diff line
@@ -21,10 +21,10 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;

import android.platform.test.annotations.RootPermissionTest;

import com.android.fsverity.AddFsVerityCertRule;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.log.LogUtil.CLog;
@@ -35,6 +35,7 @@ import com.android.tradefed.util.CommandStatus;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@@ -85,40 +86,25 @@ public class ApkVerityTest extends BaseHostJUnit4Test {
    private static final String DAMAGING_EXECUTABLE = "/data/local/tmp/block_device_writer";
    private static final String CERT_PATH = "/data/local/tmp/ApkVerityTestCert.der";

    private static final String APK_VERITY_STANDARD_MODE = "2";

    /** Only 4K page is supported by fs-verity currently. */
    private static final int FSVERITY_PAGE_SIZE = 4096;

    @Rule
    public final AddFsVerityCertRule mAddFsVerityCertRule =
            new AddFsVerityCertRule(this, CERT_PATH);

    private ITestDevice mDevice;
    private String mKeyId;

    @Before
    public void setUp() throws DeviceNotAvailableException {
        mDevice = getDevice();

        String apkVerityMode = mDevice.getProperty("ro.apk_verity.mode");
        assumeTrue(mDevice.getLaunchApiLevel() >= 30
                || APK_VERITY_STANDARD_MODE.equals(apkVerityMode));

        mKeyId = expectRemoteCommandToSucceed(
                "mini-keyctl padd asymmetric fsv_test .fs-verity < " + CERT_PATH).trim();
        if (!mKeyId.matches("^\\d+$")) {
            String keyId = mKeyId;
            mKeyId = null;
            fail("Key ID is not decimal: " + keyId);
        }

        uninstallPackage(TARGET_PACKAGE);
    }

    @After
    public void tearDown() throws DeviceNotAvailableException {
        uninstallPackage(TARGET_PACKAGE);

        if (mKeyId != null) {
            expectRemoteCommandToSucceed("mini-keyctl unlink " + mKeyId + " .fs-verity");
        }
    }

    @Test
+30 −0
Original line number Diff line number Diff line
// Copyright (C) 2021 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

java_test_host {
    name: "UpdatableSystemFontTest",
    srcs: ["src/**/*.java"],
    libs: ["tradefed", "compatibility-tradefed", "compatibility-host-util"],
    static_libs: ["frameworks-base-hostutils"],
    test_suites: ["general-tests", "vts"],
    data: [
        ":NotoColorEmojiTtf",
        ":UpdatableSystemFontTestCertDer",
        ":UpdatableSystemFontTestNotoColorEmojiTtfFsvSig",
        ":UpdatableSystemFontTestNotoColorEmojiV1Ttf",
        ":UpdatableSystemFontTestNotoColorEmojiV1TtfFsvSig",
        ":UpdatableSystemFontTestNotoColorEmojiV2Ttf",
        ":UpdatableSystemFontTestNotoColorEmojiV2TtfFsvSig",
    ],
}
Loading