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

Commit 4660f720 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Use "RavenwoodHelper"

Bug: 292141694
Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh -s
Flag: EXEMPT host side change only
Change-Id: Ib652d3504ea41dc679e8c20354e619577e627ed4
parent 1eec3dda
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -423,6 +423,7 @@ java_defaults {
        "modules-utils-preconditions",
        "modules-utils-statemachine",
        "modules-utils-os",
        "modules-utils-ravenwood",
        "modules-utils-uieventlogger-interface",
        "framework-permission-aidl-java",
        "spatializer-aidl-java",
+4 −1
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@ import android.ravenwood.annotation.RavenwoodReplace;

/**
 * Class to interact with the Ravenwood environment.
 *
 * TODO: With {@link com.android.modules.utils.ravenwood.RavenwoodHelper}, this class
 * is mostly redundant. Clean it up.
 */
@RavenwoodKeepWholeClass
@RavenwoodRedirectionClass("RavenwoodEnvironment_host")
@@ -57,7 +60,7 @@ public final class RavenwoodEnvironment {
     * <p>This should be only used when different behavior is absolutely needed.
     *
     * <p>If someone needs it without having access to the SDK, the following hack would work too.
     * <code>System.getProperty("java.class.path").contains("ravenwood")</code>
     * <code>System.getProperty("android.ravenwood.version") != null</code>
     */
    @RavenwoodReplace
    public boolean isRunningOnRavenwood() {
+2 −3
Original line number Diff line number Diff line
@@ -20,11 +20,11 @@ import static android.os.Process.FIRST_APPLICATION_UID;
import static android.os.UserHandle.SYSTEM;
import static android.platform.test.ravenwood.RavenwoodSystemServer.ANDROID_PACKAGE_NAME;

import static com.android.modules.utils.ravenwood.RavenwoodHelper.RavenwoodInternal.RAVENWOOD_RUNTIME_PATH_JAVA_SYSPROP;
import static com.android.modules.utils.ravenwood.RavenwoodHelper.RavenwoodInternal.RAVENWOOD_VERSION_JAVA_SYSPROP;
import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_EMPTY_RESOURCES_APK;
import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_INST_RESOURCE_APK;
import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_RESOURCE_APK;
import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_RUNTIME_PATH_JAVA_SYSPROP;
import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_VERSION_JAVA_SYSPROP;
import static com.android.ravenwood.common.RavenwoodCommonUtils.getRavenwoodRuntimePath;
import static com.android.ravenwood.common.RavenwoodCommonUtils.parseNullableInt;
import static com.android.ravenwood.common.RavenwoodCommonUtils.withDefault;
@@ -67,7 +67,6 @@ import android.view.DisplayAdjustments;

import androidx.test.platform.app.InstrumentationRegistry;

import com.android.hoststubgen.hosthelper.HostTestUtils;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.os.RuntimeInit;
import com.android.ravenwood.RavenwoodRuntimeNative;
+0 −4
Original line number Diff line number Diff line
@@ -70,10 +70,6 @@ public class RavenwoodCommonUtils {
    public static final String RAVENWOOD_EMPTY_RESOURCES_APK =
            RAVENWOOD_RUNTIME_PATH + "ravenwood-data/ravenwood-empty-res.apk";

    public static final String RAVENWOOD_VERSION_JAVA_SYSPROP = "android.ravenwood.version";
    public static final String RAVENWOOD_RUNTIME_PATH_JAVA_SYSPROP =
            "android.ravenwood.runtime_path";

    /**
     * @return if we're running on Ravenwood.
     */
+59 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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 com.android.ravenwoodtest.bivalenttest;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

import android.platform.test.ravenwood.RavenwoodRule;

import com.android.modules.utils.ravenwood.RavenwoodHelper;

import org.junit.Test;

import java.io.File;

public class RavenwoodHelperTest {
    @Test
    public void testIsRunningOnRavenwood() {
        assertEquals(RavenwoodRule.isOnRavenwood(), RavenwoodHelper.isRunningOnRavenwood());
    }

    @Test
    public void testRavenwoodRuntimePath() {
        // getRavenwoodRuntimePath() only works on Ravenwood.
        assumeTrue(RavenwoodRule.isOnRavenwood());

        var path = new File(RavenwoodHelper.getRavenwoodRuntimePath());

        assertTrue(path.exists());
        assertTrue(path.isDirectory());
        assertTrue(new File(path, "100-framework-minus-apex.ravenwood.jar").exists());
    }

    @Test
    public void testGetRavenwoodAconfigStoragePath() {
        // getRavenwoodAconfigStoragePath() only works on Ravenwood.
        assumeTrue(RavenwoodRule.isOnRavenwood());

        var path = new File(RavenwoodHelper.getRavenwoodAconfigStoragePath());

        assertTrue(path.exists());
        assertTrue(path.isDirectory());
        assertTrue(new File(path, "metadata").exists());
    }
}
Loading