Loading packages/NeuralNetworks/service/java/com/android/server/ondeviceintelligence/BundleUtil.java +2 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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"); Loading services/tests/ondeviceintelligencetests/Android.bp +6 −2 Original line number Diff line number Diff line Loading @@ -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"], Loading services/tests/ondeviceintelligencetests/src/com/android/server/ondeviceintelligence/InferenceInfoStoreTest.java +6 −5 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading Loading
packages/NeuralNetworks/service/java/com/android/server/ondeviceintelligence/BundleUtil.java +2 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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"); Loading
services/tests/ondeviceintelligencetests/Android.bp +6 −2 Original line number Diff line number Diff line Loading @@ -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"], Loading
services/tests/ondeviceintelligencetests/src/com/android/server/ondeviceintelligence/InferenceInfoStoreTest.java +6 −5 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading