diff options
author | 2024-12-05 15:35:29 +0000 | |
---|---|---|
committer | 2024-12-05 15:35:29 +0000 | |
commit | e9b791bbc3dc96f2bfd3cd3cabb9a6d7c28e779e (patch) | |
tree | 55568d7e564c268ae588b629c2c2216309e3836c | |
parent | e5c01633420af6432858d90667e4c393cc2e571c (diff) |
Fix test failure caused due to missing deps
* Add jar dependencies when RELEASE_ONDEVICE_INTELLIGENCE_MODULE is true.
Change-Id: I4150b16f8a57f697e54d4e60fc5ee35713e10bdb
Flag: build.release_ondevice_intelligence_module
Bug: 376427781
3 files changed, 14 insertions, 7 deletions
diff --git a/packages/NeuralNetworks/service/java/com/android/server/ondeviceintelligence/BundleUtil.java b/packages/NeuralNetworks/service/java/com/android/server/ondeviceintelligence/BundleUtil.java index 53ef9e889997..2626cc880e09 100644 --- a/packages/NeuralNetworks/service/java/com/android/server/ondeviceintelligence/BundleUtil.java +++ b/packages/NeuralNetworks/service/java/com/android/server/ondeviceintelligence/BundleUtil.java @@ -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"); diff --git a/services/tests/ondeviceintelligencetests/Android.bp b/services/tests/ondeviceintelligencetests/Android.bp index a31a3fb65700..f235da2fea7f 100644 --- a/services/tests/ondeviceintelligencetests/Android.bp +++ b/services/tests/ondeviceintelligencetests/Android.bp @@ -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"], diff --git a/services/tests/ondeviceintelligencetests/src/com/android/server/ondeviceintelligence/InferenceInfoStoreTest.java b/services/tests/ondeviceintelligencetests/src/com/android/server/ondeviceintelligence/InferenceInfoStoreTest.java index d12579cd6b11..28ccb84c38f3 100644 --- a/services/tests/ondeviceintelligencetests/src/com/android/server/ondeviceintelligence/InferenceInfoStoreTest.java +++ b/services/tests/ondeviceintelligencetests/src/com/android/server/ondeviceintelligence/InferenceInfoStoreTest.java @@ -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); |