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

Commit c69a84e4 authored by Makoto Onuki's avatar Makoto Onuki Committed by Jeff Sharkey
Browse files

Add `android_ravenwood_test` build rule

Since we're unable to compile libcore classes for the device,
we temporarily pivot usages to our own copy of EmptyArray.

Bug: 292141694
Test: m nothing --no-skip-soong-tests
Test: m hoststubgen ravenwood-runtime tradefed atest && atest-dev HostStubGenTest-framework-test
Change-Id: I9d4ff559924e47725eb3e897aaf2cc93e9b1a193
parent 5d37f327
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
// limitations under the License.

// We need this "trampoline" rule to force soong to give a host-side jar to
// framework-minus-apex.ravenwood. Otherwise, soong would mix up the arch (?) and we'd get
// framework-minus-apex.ravenwood-base. Otherwise, soong would mix up the arch (?) and we'd get
// a dex jar.
java_library {
    name: "framework-minus-apex-for-hoststubgen",
@@ -26,7 +26,7 @@ java_library {
}

// Generate the stub/impl from framework-all, with hidden APIs.
java_genrule_host {
java_genrule {
    name: "framework-minus-apex.ravenwood-base",
    tools: ["hoststubgen"],
    cmd: "$(location hoststubgen) " +
@@ -57,7 +57,9 @@ java_genrule_host {
}

// Extract the impl jar from "framework-minus-apex.ravenwood-base" for subsequent build rules.
java_genrule_host {
// Note this emits a "device side" output, so that ravenwood tests can (implicitly)
// depend on it.
java_genrule {
    name: "framework-minus-apex.ravenwood",
    defaults: ["hoststubgen-for-prototype-only-genrule"],
    cmd: "cp $(in) $(out)",
@@ -68,3 +70,17 @@ java_genrule_host {
        "framework-minus-apex.ravenwood.jar",
    ],
}

android_ravenwood_libgroup {
    name: "ravenwood-runtime",
    libs: [
        "framework-minus-apex.ravenwood",
        "hoststubgen-helper-runtime.ravenwood",
        "hoststubgen-helper-framework-runtime.ravenwood",
    ],
}

android_ravenwood_libgroup {
    name: "ravenwood-utils",
    libs: [],
}
+0 −2
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ import android.compat.annotation.UnsupportedAppUsage;

import com.android.internal.util.ArrayUtils;

import libcore.util.EmptyArray;

import java.util.Arrays;
import java.util.Collection;
import java.util.ConcurrentModificationException;
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.
 */

package android.util;

import android.annotation.NonNull;

/**
 * Empty array is immutable. Use a shared empty array to avoid allocation.
 *
 * @hide
 */
public final class EmptyArray {
    private EmptyArray() {}

    public static final @NonNull boolean[] BOOLEAN = new boolean[0];
    public static final @NonNull byte[] BYTE = new byte[0];
    public static final @NonNull char[] CHAR = new char[0];
    public static final @NonNull double[] DOUBLE = new double[0];
    public static final @NonNull float[] FLOAT = new float[0];
    public static final @NonNull int[] INT = new int[0];
    public static final @NonNull long[] LONG = new long[0];
    public static final @NonNull Object[] OBJECT = new Object[0];
    public static final @NonNull String[] STRING = new String[0];
}
+8 −0
Original line number Diff line number Diff line
# Ravenwood "policy" file for framework-minus-apex.

class android.util.ArrayMap stubclass
class android.util.ContainerHelpers stubclass
class android.util.EmptyArray stubclass
class android.util.MapCollections stubclass

class android.util.Log stubclass
class android.util.Log !com.android.hoststubgen.nativesubstitution.Log_host
+30 −2
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ genrule_defaults {
    name: "hoststubgen-for-prototype-only-genrule",
    visibility: [
        ":__subpackages__",
        "//frameworks/base",
        "//frameworks/base/ravenwood:__subpackages__",
    ],
}
@@ -21,6 +22,7 @@ java_defaults {
    name: "hoststubgen-for-prototype-only-java",
    visibility: [
        ":__subpackages__",
        "//frameworks/base",
        "//frameworks/base/ravenwood:__subpackages__",
    ],
}
@@ -30,6 +32,7 @@ filegroup_defaults {
    name: "hoststubgen-for-prototype-only-filegroup",
    visibility: [
        ":__subpackages__",
        "//frameworks/base",
        "//frameworks/base/ravenwood:__subpackages__",
    ],
}
@@ -44,8 +47,6 @@ java_library {
    ],
    host_supported: true,

    // Seems like we need it to avoid circular deps.
    // Copied it from "app-compat-annotations".
    sdk_version: "core_current",
}

@@ -66,6 +67,21 @@ java_library_host {
    visibility: ["//visibility:public"],
}

java_library {
    name: "hoststubgen-helper-runtime.ravenwood",
    srcs: [
        "helper-runtime-src/**/*.java",
    ],
    libs: [
        "junit",
    ],
    static_libs: [
        "guava",
    ],
    jarjar_rules: "jarjar-rules.txt",
    visibility: ["//visibility:public"],
}

// Host-side stub generator tool.
java_binary_host {
    name: "hoststubgen",
@@ -245,6 +261,18 @@ java_library_host {
    ],
}

java_library {
    name: "hoststubgen-helper-framework-runtime.ravenwood",
    defaults: ["hoststubgen-for-prototype-only-java"],
    srcs: [
        "helper-framework-runtime-src/framework/**/*.java",
    ],
    libs: [
        "hoststubgen-helper-runtime.ravenwood",
        "framework-minus-apex.ravenwood",
    ],
}

// Defaults for host side test modules.
// We need two rules for each test.
// 1. A "-test-lib" jar, which compiles the test against the stub jar.
Loading