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

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

Merge "Fix test failure caused due to missing deps" into main

parents 998e7bd5 e9b791bb
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.system.OsConstants.O_ACCMODE;
import static android.system.OsConstants.O_RDONLY;
import static android.system.OsConstants.PROT_READ;

import android.annotation.SuppressLint;
import android.app.ondeviceintelligence.IResponseCallback;
import android.app.ondeviceintelligence.IStreamingResponseCallback;
import android.app.ondeviceintelligence.ITokenInfoCallback;
@@ -328,6 +329,7 @@ public class BundleUtil {
                (value instanceof Boolean) || (value instanceof boolean[]);
    }

    @SuppressLint("NewApi")
    private static void ensureValidBundle(Bundle bundle) {
        if (bundle == null) {
            throw new IllegalArgumentException("Request passed is expected to be non-null");
+6 −2
Original line number Diff line number Diff line
@@ -44,14 +44,18 @@ android_test {
        "truth",
        "frameworks-base-testutils",
        "androidx.test.rules",
    ] + select(soong_config_variable("ANDROID", "release_ondevice_intelligence_module"), {
        "true": [
            "service-ondeviceintelligence.impl",
        ],
        default: [],
    }),

    libs: [
        "android.test.mock.stubs.system",
        "android.test.base.stubs.system",
        "android.test.runner.stubs.system",
    ],

    certificate: "platform",
    platform_apis: true,
    test_suites: ["device-tests"],
+6 −5
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertThat;
import android.app.ondeviceintelligence.InferenceInfo;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.service.ondeviceintelligence.OnDeviceSandboxedInferenceService;
import android.util.Base64;

import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -38,6 +37,8 @@ import java.util.List;
public class InferenceInfoStoreTest {
    InferenceInfoStore inferenceInfoStore;

    public static final String INFERENCE_INFO_BUNDLE_KEY = "inference_info";

    @Before
    public void setUp() {
        inferenceInfoStore = new InferenceInfoStore(1000);
@@ -46,7 +47,7 @@ public class InferenceInfoStoreTest {
    @Test
    public void testInferenceInfoParsesFromBundleSuccessfully() throws Exception {
        Bundle bundle = new Bundle();
        bundle.putByteArray(OnDeviceSandboxedInferenceService.INFERENCE_INFO_BUNDLE_KEY,
        bundle.putByteArray(INFERENCE_INFO_BUNDLE_KEY,
                getInferenceInfoBytes(1, 1, 100));
        inferenceInfoStore.addInferenceInfoFromBundle(bundle);
        List<InferenceInfo> inferenceInfos = inferenceInfoStore.getLatestInferenceInfo(0);
@@ -59,7 +60,7 @@ public class InferenceInfoStoreTest {
    @Test
    public void testInferenceInfoParsesFromPersistableBundleSuccessfully() throws Exception {
        PersistableBundle bundle = new PersistableBundle();
        bundle.putString(OnDeviceSandboxedInferenceService.INFERENCE_INFO_BUNDLE_KEY,
        bundle.putString(INFERENCE_INFO_BUNDLE_KEY,
                Base64.encodeToString(getInferenceInfoBytes(1, 1, 100), Base64.DEFAULT));
        inferenceInfoStore.addInferenceInfoFromBundle(bundle);
        List<InferenceInfo> inferenceInfos = inferenceInfoStore.getLatestInferenceInfo(0);
@@ -74,11 +75,11 @@ public class InferenceInfoStoreTest {
    public void testEvictionAfterMaxAge() throws Exception {
        PersistableBundle bundle = new PersistableBundle();
        long testStartTime = System.currentTimeMillis();
        bundle.putString(OnDeviceSandboxedInferenceService.INFERENCE_INFO_BUNDLE_KEY,
        bundle.putString(INFERENCE_INFO_BUNDLE_KEY,
                Base64.encodeToString(getInferenceInfoBytes(1,  testStartTime - 10,
                        testStartTime + 100), Base64.DEFAULT));
        inferenceInfoStore.addInferenceInfoFromBundle(bundle);
        bundle.putString(OnDeviceSandboxedInferenceService.INFERENCE_INFO_BUNDLE_KEY,
        bundle.putString(INFERENCE_INFO_BUNDLE_KEY,
                Base64.encodeToString(getInferenceInfoBytes(1, testStartTime - 5,
                        testStartTime + 100), Base64.DEFAULT));
        inferenceInfoStore.addInferenceInfoFromBundle(bundle);