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

Commit 2174c06d authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use "RavenwoodHelper"" into main

parents 15e6f796 4660f720
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -419,6 +419,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 −2
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;
+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