Rename onEvent to onWebViewEvent.
Bug: 228200518
Test: atest
Change-Id: I28e3e63ea0f937816c7a10bf78c755dd9327a76b
diff --git a/framework/java/android/ondevicepersonalization/Constants.java b/framework/java/android/ondevicepersonalization/Constants.java
index 9820b29..e3b743f 100644
--- a/framework/java/android/ondevicepersonalization/Constants.java
+++ b/framework/java/android/ondevicepersonalization/Constants.java
@@ -29,7 +29,7 @@
public static final int OP_EXECUTE = 1;
public static final int OP_DOWNLOAD = 2;
public static final int OP_RENDER = 3;
- public static final int OP_EVENT = 4;
+ public static final int OP_WEB_VIEW_EVENT = 4;
// Keys for Bundle objects passed between processes.
public static final String
diff --git a/framework/java/android/ondevicepersonalization/EventInput.aidl b/framework/java/android/ondevicepersonalization/EventInput.aidl
deleted file mode 100644
index 87d1b7e..0000000
--- a/framework/java/android/ondevicepersonalization/EventInput.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2023 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 android.ondevicepersonalization;
-
-parcelable EventInput;
diff --git a/framework/java/android/ondevicepersonalization/IsolatedComputationCallback.java b/framework/java/android/ondevicepersonalization/IsolatedComputationCallback.java
index 4073660..4b69590 100644
--- a/framework/java/android/ondevicepersonalization/IsolatedComputationCallback.java
+++ b/framework/java/android/ondevicepersonalization/IsolatedComputationCallback.java
@@ -56,11 +56,10 @@
}
/**
- * Generate HTML for the winning bids that returned as a result of {@link execute}.
+ * Generate HTML for the results that were returned as a result of {@link execute}.
* The platform will render this HTML in a WebView inside a fenced frame.
*
* @param input Parameters for the renderContent request.
- * @param odpContext The per-request state for this request.
* @param consumer Callback to be invoked on completion.
*/
default void onRender(
@@ -71,16 +70,14 @@
}
/**
- * Compute a list of metrics to be logged in the events table with this event.
+ * Generate an event to be logged from an event tracking URL.
*
- * @param input The query-time data required to compute the event metrics.
- * @param odpContext The per-request state for this request.
+ * @param input The parameters needed to compute event data.
* @param consumer Callback to be invoked on completion.
*/
- // TODO(b/259950177): Also provide the Query event from the Query table.
- default void onEvent(
- @NonNull EventInput input,
- @NonNull Consumer<EventOutput> consumer
+ default void onWebViewEvent(
+ @NonNull WebViewEventInput input,
+ @NonNull Consumer<WebViewEventOutput> consumer
) {
consumer.accept(null);
}
diff --git a/framework/java/android/ondevicepersonalization/IsolatedComputationService.java b/framework/java/android/ondevicepersonalization/IsolatedComputationService.java
index 7926bd5..d0c68d9 100644
--- a/framework/java/android/ondevicepersonalization/IsolatedComputationService.java
+++ b/framework/java/android/ondevicepersonalization/IsolatedComputationService.java
@@ -148,17 +148,17 @@
implCallback.onRender(
input, new WrappedCallback<RenderOutput>(resultCallback));
- } else if (operationCode == Constants.OP_EVENT) {
+ } else if (operationCode == Constants.OP_WEB_VIEW_EVENT) {
- EventInput input = Objects.requireNonNull(
- params.getParcelable(Constants.EXTRA_INPUT, EventInput.class));
+ WebViewEventInput input = Objects.requireNonNull(
+ params.getParcelable(Constants.EXTRA_INPUT, WebViewEventInput.class));
IDataAccessService binder =
IDataAccessService.Stub.asInterface(Objects.requireNonNull(
params.getBinder(Constants.EXTRA_DATA_ACCESS_SERVICE_BINDER)));
RequestToken requestToken = new RequestToken(binder);
IsolatedComputationCallback implCallback = createCallback(requestToken);
- implCallback.onEvent(
- input, new WrappedCallback<EventOutput>(resultCallback));
+ implCallback.onWebViewEvent(
+ input, new WrappedCallback<WebViewEventOutput>(resultCallback));
} else {
throw new IllegalArgumentException("Invalid op code: " + operationCode);
diff --git a/framework/java/android/ondevicepersonalization/EventOutput.aidl b/framework/java/android/ondevicepersonalization/WebViewEventInput.aidl
similarity index 95%
rename from framework/java/android/ondevicepersonalization/EventOutput.aidl
rename to framework/java/android/ondevicepersonalization/WebViewEventInput.aidl
index 4687c04..7f2a704 100644
--- a/framework/java/android/ondevicepersonalization/EventOutput.aidl
+++ b/framework/java/android/ondevicepersonalization/WebViewEventInput.aidl
@@ -16,4 +16,4 @@
package android.ondevicepersonalization;
-parcelable EventOutput;
+parcelable WebViewEventInput;
diff --git a/framework/java/android/ondevicepersonalization/EventInput.java b/framework/java/android/ondevicepersonalization/WebViewEventInput.java
similarity index 85%
rename from framework/java/android/ondevicepersonalization/EventInput.java
rename to framework/java/android/ondevicepersonalization/WebViewEventInput.java
index e427201..364fc13 100644
--- a/framework/java/android/ondevicepersonalization/EventInput.java
+++ b/framework/java/android/ondevicepersonalization/WebViewEventInput.java
@@ -28,7 +28,7 @@
* @hide
*/
@DataClass(genBuilder = true, genEqualsHashCode = true)
-public final class EventInput implements Parcelable {
+public final class WebViewEventInput implements Parcelable {
/** The rows that were logged as a result of onExecute. */
@Nullable private RequestLogRecord mRequestLogRecord = null;
@@ -43,7 +43,7 @@
// CHECKSTYLE:OFF Generated code
//
// To regenerate run:
- // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/EventInput.java
+ // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/WebViewEventInput.java
//
// To exclude the generated code from IntelliJ auto-formatting enable (one-time):
// Settings > Editor > Code Style > Formatter Control
@@ -51,7 +51,7 @@
@DataClass.Generated.Member
- /* package-private */ EventInput(
+ /* package-private */ WebViewEventInput(
@Nullable RequestLogRecord requestLogRecord,
@Nullable PersistableBundle parameters) {
this.mRequestLogRecord = requestLogRecord;
@@ -80,13 +80,13 @@
@DataClass.Generated.Member
public boolean equals(@Nullable Object o) {
// You can override field equality logic by defining either of the methods like:
- // boolean fieldNameEquals(EventInput other) { ... }
+ // boolean fieldNameEquals(WebViewEventInput other) { ... }
// boolean fieldNameEquals(FieldType otherValue) { ... }
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@SuppressWarnings("unchecked")
- EventInput that = (EventInput) o;
+ WebViewEventInput that = (WebViewEventInput) o;
//noinspection PointlessBooleanExpression
return true
&& java.util.Objects.equals(mRequestLogRecord, that.mRequestLogRecord)
@@ -126,7 +126,7 @@
/** @hide */
@SuppressWarnings({"unchecked", "RedundantCast"})
@DataClass.Generated.Member
- /* package-private */ EventInput(@android.annotation.NonNull android.os.Parcel in) {
+ /* package-private */ WebViewEventInput(@android.annotation.NonNull android.os.Parcel in) {
// You can override field unparcelling by defining methods like:
// static FieldType unparcelFieldName(Parcel in) { ... }
@@ -141,21 +141,21 @@
}
@DataClass.Generated.Member
- public static final @android.annotation.NonNull Parcelable.Creator<EventInput> CREATOR
- = new Parcelable.Creator<EventInput>() {
+ public static final @android.annotation.NonNull Parcelable.Creator<WebViewEventInput> CREATOR
+ = new Parcelable.Creator<WebViewEventInput>() {
@Override
- public EventInput[] newArray(int size) {
- return new EventInput[size];
+ public WebViewEventInput[] newArray(int size) {
+ return new WebViewEventInput[size];
}
@Override
- public EventInput createFromParcel(@android.annotation.NonNull android.os.Parcel in) {
- return new EventInput(in);
+ public WebViewEventInput createFromParcel(@android.annotation.NonNull android.os.Parcel in) {
+ return new WebViewEventInput(in);
}
};
/**
- * A builder for {@link EventInput}
+ * A builder for {@link WebViewEventInput}
*/
@SuppressWarnings("WeakerAccess")
@DataClass.Generated.Member
@@ -192,7 +192,7 @@
}
/** Builds the instance. This builder should not be touched after calling this! */
- public @android.annotation.NonNull EventInput build() {
+ public @android.annotation.NonNull WebViewEventInput build() {
checkNotUsed();
mBuilderFieldsSet |= 0x4; // Mark builder used
@@ -202,7 +202,7 @@
if ((mBuilderFieldsSet & 0x2) == 0) {
mParameters = null;
}
- EventInput o = new EventInput(
+ WebViewEventInput o = new WebViewEventInput(
mRequestLogRecord,
mParameters);
return o;
@@ -217,10 +217,10 @@
}
@DataClass.Generated(
- time = 1686601825094L,
+ time = 1686948744738L,
codegenVersion = "1.0.23",
- sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/EventInput.java",
- inputSignatures = "private @android.annotation.Nullable android.ondevicepersonalization.RequestLogRecord mRequestLogRecord\nprivate @android.annotation.Nullable android.os.PersistableBundle mParameters\nclass EventInput extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
+ sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/WebViewEventInput.java",
+ inputSignatures = "private @android.annotation.Nullable android.ondevicepersonalization.RequestLogRecord mRequestLogRecord\nprivate @android.annotation.Nullable android.os.PersistableBundle mParameters\nclass WebViewEventInput extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
@Deprecated
private void __metadata() {}
diff --git a/framework/java/android/ondevicepersonalization/EventOutput.aidl b/framework/java/android/ondevicepersonalization/WebViewEventOutput.aidl
similarity index 95%
copy from framework/java/android/ondevicepersonalization/EventOutput.aidl
copy to framework/java/android/ondevicepersonalization/WebViewEventOutput.aidl
index 4687c04..812ea74 100644
--- a/framework/java/android/ondevicepersonalization/EventOutput.aidl
+++ b/framework/java/android/ondevicepersonalization/WebViewEventOutput.aidl
@@ -16,4 +16,4 @@
package android.ondevicepersonalization;
-parcelable EventOutput;
+parcelable WebViewEventOutput;
diff --git a/framework/java/android/ondevicepersonalization/EventOutput.java b/framework/java/android/ondevicepersonalization/WebViewEventOutput.java
similarity index 81%
rename from framework/java/android/ondevicepersonalization/EventOutput.java
rename to framework/java/android/ondevicepersonalization/WebViewEventOutput.java
index 1938366..72f79ff 100644
--- a/framework/java/android/ondevicepersonalization/EventOutput.java
+++ b/framework/java/android/ondevicepersonalization/WebViewEventOutput.java
@@ -27,7 +27,7 @@
* @hide
*/
@DataClass(genBuilder = true, genEqualsHashCode = true)
-public final class EventOutput implements Parcelable {
+public final class WebViewEventOutput implements Parcelable {
/** Additional data to be written to the log, if not null. */
@Nullable EventLogRecord mEventLogRecord = null;
@@ -39,7 +39,7 @@
// CHECKSTYLE:OFF Generated code
//
// To regenerate run:
- // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/EventOutput.java
+ // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/WebViewEventOutput.java
//
// To exclude the generated code from IntelliJ auto-formatting enable (one-time):
// Settings > Editor > Code Style > Formatter Control
@@ -47,7 +47,7 @@
@DataClass.Generated.Member
- /* package-private */ EventOutput(
+ /* package-private */ WebViewEventOutput(
@Nullable EventLogRecord eventLogRecord) {
this.mEventLogRecord = eventLogRecord;
@@ -66,13 +66,13 @@
@DataClass.Generated.Member
public boolean equals(@Nullable Object o) {
// You can override field equality logic by defining either of the methods like:
- // boolean fieldNameEquals(EventOutput other) { ... }
+ // boolean fieldNameEquals(WebViewEventOutput other) { ... }
// boolean fieldNameEquals(FieldType otherValue) { ... }
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@SuppressWarnings("unchecked")
- EventOutput that = (EventOutput) o;
+ WebViewEventOutput that = (WebViewEventOutput) o;
//noinspection PointlessBooleanExpression
return true
&& java.util.Objects.equals(mEventLogRecord, that.mEventLogRecord);
@@ -108,7 +108,7 @@
/** @hide */
@SuppressWarnings({"unchecked", "RedundantCast"})
@DataClass.Generated.Member
- /* package-private */ EventOutput(@android.annotation.NonNull android.os.Parcel in) {
+ /* package-private */ WebViewEventOutput(@android.annotation.NonNull android.os.Parcel in) {
// You can override field unparcelling by defining methods like:
// static FieldType unparcelFieldName(Parcel in) { ... }
@@ -121,21 +121,21 @@
}
@DataClass.Generated.Member
- public static final @android.annotation.NonNull Parcelable.Creator<EventOutput> CREATOR
- = new Parcelable.Creator<EventOutput>() {
+ public static final @android.annotation.NonNull Parcelable.Creator<WebViewEventOutput> CREATOR
+ = new Parcelable.Creator<WebViewEventOutput>() {
@Override
- public EventOutput[] newArray(int size) {
- return new EventOutput[size];
+ public WebViewEventOutput[] newArray(int size) {
+ return new WebViewEventOutput[size];
}
@Override
- public EventOutput createFromParcel(@android.annotation.NonNull android.os.Parcel in) {
- return new EventOutput(in);
+ public WebViewEventOutput createFromParcel(@android.annotation.NonNull android.os.Parcel in) {
+ return new WebViewEventOutput(in);
}
};
/**
- * A builder for {@link EventOutput}
+ * A builder for {@link WebViewEventOutput}
*/
@SuppressWarnings("WeakerAccess")
@DataClass.Generated.Member
@@ -160,14 +160,14 @@
}
/** Builds the instance. This builder should not be touched after calling this! */
- public @android.annotation.NonNull EventOutput build() {
+ public @android.annotation.NonNull WebViewEventOutput build() {
checkNotUsed();
mBuilderFieldsSet |= 0x2; // Mark builder used
if ((mBuilderFieldsSet & 0x1) == 0) {
mEventLogRecord = null;
}
- EventOutput o = new EventOutput(
+ WebViewEventOutput o = new WebViewEventOutput(
mEventLogRecord);
return o;
}
@@ -181,10 +181,10 @@
}
@DataClass.Generated(
- time = 1686601819831L,
+ time = 1686948819983L,
codegenVersion = "1.0.23",
- sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/EventOutput.java",
- inputSignatures = " @android.annotation.Nullable android.ondevicepersonalization.EventLogRecord mEventLogRecord\nclass EventOutput extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
+ sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/WebViewEventOutput.java",
+ inputSignatures = " @android.annotation.Nullable android.ondevicepersonalization.EventLogRecord mEventLogRecord\nclass WebViewEventOutput extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
@Deprecated
private void __metadata() {}
diff --git a/src/com/android/ondevicepersonalization/services/display/OdpWebViewClient.java b/src/com/android/ondevicepersonalization/services/display/OdpWebViewClient.java
index 370d881..0aefacd 100644
--- a/src/com/android/ondevicepersonalization/services/display/OdpWebViewClient.java
+++ b/src/com/android/ondevicepersonalization/services/display/OdpWebViewClient.java
@@ -21,10 +21,10 @@
import android.content.Intent;
import android.net.Uri;
import android.ondevicepersonalization.Constants;
-import android.ondevicepersonalization.EventInput;
import android.ondevicepersonalization.EventLogRecord;
-import android.ondevicepersonalization.EventOutput;
import android.ondevicepersonalization.RequestLogRecord;
+import android.ondevicepersonalization.WebViewEventInput;
+import android.ondevicepersonalization.WebViewEventOutput;
import android.os.Bundle;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
@@ -158,7 +158,7 @@
return true;
}
- private ListenableFuture<EventOutput> executeEventHandler(
+ private ListenableFuture<WebViewEventOutput> executeEventHandler(
IsolatedServiceInfo isolatedServiceInfo, EventUrlPayload payload) {
try {
sLogger.d(TAG + ": executeEventHandler() called");
@@ -167,7 +167,7 @@
mServicePackageName, mContext, true);
serviceParams.putBinder(Constants.EXTRA_DATA_ACCESS_SERVICE_BINDER, binder);
// TODO(b/259950177): Add Query row to input.
- EventInput input = new EventInput.Builder()
+ WebViewEventInput input = new WebViewEventInput.Builder()
.setParameters(payload.getEventParams())
.setRequestLogRecord(mLogRecord)
.build();
@@ -177,11 +177,11 @@
isolatedServiceInfo,
AppManifestConfigHelper.getServiceNameFromOdpSettings(
mContext, mServicePackageName),
- Constants.OP_EVENT,
+ Constants.OP_WEB_VIEW_EVENT,
serviceParams))
.transform(
result -> result.getParcelable(
- Constants.EXTRA_RESULT, EventOutput.class),
+ Constants.EXTRA_RESULT, WebViewEventOutput.class),
mInjector.getExecutor());
} catch (Exception e) {
sLogger.e(TAG + ": executeEventHandler() failed", e);
@@ -190,7 +190,7 @@
}
- ListenableFuture<EventOutput> getEventOutput(EventUrlPayload payload) {
+ ListenableFuture<WebViewEventOutput> getEventOutput(EventUrlPayload payload) {
try {
sLogger.d(TAG + ": getEventOutput(): Starting isolated process.");
return FluentFuture.from(ProcessUtils.loadIsolatedService(
@@ -205,7 +205,7 @@
}
}
- private ListenableFuture<Void> writeEvent(EventOutput result) {
+ private ListenableFuture<Void> writeEvent(WebViewEventOutput result) {
try {
sLogger.d(TAG + ": writeEvent() called. EventOutput: " + result.toString());
if (result == null || result.getEventLogRecord() == null) {
diff --git a/tests/endtoendtests/OdpSampleNetwork/src/com/android/odpsamplenetwork/SampleHandler.java b/tests/endtoendtests/OdpSampleNetwork/src/com/android/odpsamplenetwork/SampleHandler.java
index 69bba8c..d4a3646 100644
--- a/tests/endtoendtests/OdpSampleNetwork/src/com/android/odpsamplenetwork/SampleHandler.java
+++ b/tests/endtoendtests/OdpSampleNetwork/src/com/android/odpsamplenetwork/SampleHandler.java
@@ -20,9 +20,7 @@
import android.content.ContentValues;
import android.ondevicepersonalization.DownloadInput;
import android.ondevicepersonalization.DownloadOutput;
-import android.ondevicepersonalization.EventInput;
import android.ondevicepersonalization.EventLogRecord;
-import android.ondevicepersonalization.EventOutput;
import android.ondevicepersonalization.EventUrlProvider;
import android.ondevicepersonalization.ExecuteInput;
import android.ondevicepersonalization.ExecuteOutput;
@@ -32,6 +30,8 @@
import android.ondevicepersonalization.RenderOutput;
import android.ondevicepersonalization.RenderingData;
import android.ondevicepersonalization.RequestLogRecord;
+import android.ondevicepersonalization.WebViewEventInput;
+import android.ondevicepersonalization.WebViewEventOutput;
import android.os.PersistableBundle;
import android.os.Process;
import android.os.StrictMode;
@@ -117,12 +117,12 @@
sBackgroundExecutor.execute(() -> handleOnRender(input, consumer));
}
- @Override public void onEvent(
- @NonNull EventInput input,
- @NonNull Consumer<EventOutput> consumer) {
- Log.d(TAG, "onEvent() started.");
+ @Override public void onWebViewEvent(
+ @NonNull WebViewEventInput input,
+ @NonNull Consumer<WebViewEventOutput> consumer) {
+ Log.d(TAG, "onWebViewEvent() started.");
sBackgroundExecutor.execute(
- () -> handleOnEvent(input, consumer));
+ () -> handleOnWebViewEvent(input, consumer));
}
private ListenableFuture<List<Ad>> readAds(KeyValueStore remoteData) {
@@ -325,15 +325,15 @@
}
}
- public void handleOnEvent(
- @NonNull EventInput input,
- @NonNull Consumer<EventOutput> consumer) {
+ public void handleOnWebViewEvent(
+ @NonNull WebViewEventInput input,
+ @NonNull Consumer<WebViewEventOutput> consumer) {
try {
Log.d(TAG, "handleOnEvent() started.");
PersistableBundle eventParams = input.getParameters();
int eventType = eventParams.getInt(EVENT_TYPE_KEY);
if (eventType <= 0) {
- consumer.accept(new EventOutput.Builder().build());
+ consumer.accept(new WebViewEventOutput.Builder().build());
return;
}
ContentValues logData = null;
@@ -352,7 +352,7 @@
logData = new ContentValues();
logData.put(CLICK_COST_KEY, updatedPrice);
}
- EventOutput result = new EventOutput.Builder()
+ WebViewEventOutput result = new WebViewEventOutput.Builder()
.setEventLogRecord(
new EventLogRecord.Builder()
.setRowIndex(0)
diff --git a/tests/frameworktests/src/android/ondevicepersonalization/IsolatedComputationServiceTest.java b/tests/frameworktests/src/android/ondevicepersonalization/IsolatedComputationServiceTest.java
index e5a8134..95e0980 100644
--- a/tests/frameworktests/src/android/ondevicepersonalization/IsolatedComputationServiceTest.java
+++ b/tests/frameworktests/src/android/ondevicepersonalization/IsolatedComputationServiceTest.java
@@ -376,35 +376,35 @@
}
@Test
- public void testOnEvent() throws Exception {
+ public void testOnWebViewEvent() throws Exception {
Bundle params = new Bundle();
params.putParcelable(
Constants.EXTRA_INPUT,
- new EventInput.Builder().setParameters(PersistableBundle.EMPTY).build());
+ new WebViewEventInput.Builder().setParameters(PersistableBundle.EMPTY).build());
params.putBinder(Constants.EXTRA_DATA_ACCESS_SERVICE_BINDER, new TestDataAccessService());
mBinder.onRequest(
- Constants.OP_EVENT, params,
+ Constants.OP_WEB_VIEW_EVENT, params,
new TestServiceCallback());
mLatch.await();
assertTrue(mOnEventCalled);
- EventOutput result =
- mCallbackResult.getParcelable(Constants.EXTRA_RESULT, EventOutput.class);
+ WebViewEventOutput result =
+ mCallbackResult.getParcelable(Constants.EXTRA_RESULT, WebViewEventOutput.class);
assertEquals(1, result.getEventLogRecord().getType());
assertEquals(2, result.getEventLogRecord().getRowIndex());
}
@Test
- public void testOnEventPropagatesError() throws Exception {
+ public void testOnWebViewEventPropagatesError() throws Exception {
PersistableBundle eventParams = new PersistableBundle();
// Input value 9999 will trigger an error in the mock service.
eventParams.putInt(EVENT_TYPE_KEY, 9999);
Bundle params = new Bundle();
params.putParcelable(
Constants.EXTRA_INPUT,
- new EventInput.Builder().setParameters(eventParams).build());
+ new WebViewEventInput.Builder().setParameters(eventParams).build());
params.putBinder(Constants.EXTRA_DATA_ACCESS_SERVICE_BINDER, new TestDataAccessService());
mBinder.onRequest(
- Constants.OP_EVENT, params,
+ Constants.OP_WEB_VIEW_EVENT, params,
new TestServiceCallback());
mLatch.await();
assertTrue(mOnEventCalled);
@@ -412,56 +412,56 @@
}
@Test
- public void testOnEventThrowsIfParamsMissing() throws Exception {
+ public void testOnWebViewEventThrowsIfParamsMissing() throws Exception {
assertThrows(
NullPointerException.class,
() -> {
mBinder.onRequest(
- Constants.OP_EVENT, null,
+ Constants.OP_WEB_VIEW_EVENT, null,
new TestServiceCallback());
});
}
@Test
- public void testOnEventThrowsIfInputMissing() throws Exception {
+ public void testOnWebViewEventThrowsIfInputMissing() throws Exception {
Bundle params = new Bundle();
params.putBinder(Constants.EXTRA_DATA_ACCESS_SERVICE_BINDER, new TestDataAccessService());
assertThrows(
NullPointerException.class,
() -> {
mBinder.onRequest(
- Constants.OP_EVENT, params,
+ Constants.OP_WEB_VIEW_EVENT, params,
new TestServiceCallback());
});
}
@Test
- public void testOnEventThrowsIfDataAccessServiceMissing() throws Exception {
+ public void testOnWebViewEventThrowsIfDataAccessServiceMissing() throws Exception {
Bundle params = new Bundle();
params.putParcelable(
Constants.EXTRA_INPUT,
- new EventInput.Builder().setParameters(PersistableBundle.EMPTY).build());
+ new WebViewEventInput.Builder().setParameters(PersistableBundle.EMPTY).build());
assertThrows(
NullPointerException.class,
() -> {
mBinder.onRequest(
- Constants.OP_EVENT, params,
+ Constants.OP_WEB_VIEW_EVENT, params,
new TestServiceCallback());
});
}
@Test
- public void testOnEventThrowsIfCallbackMissing() throws Exception {
+ public void testOnWebViewEventThrowsIfCallbackMissing() throws Exception {
Bundle params = new Bundle();
params.putParcelable(
Constants.EXTRA_INPUT,
- new EventInput.Builder().setParameters(PersistableBundle.EMPTY).build());
+ new WebViewEventInput.Builder().setParameters(PersistableBundle.EMPTY).build());
params.putBinder(Constants.EXTRA_DATA_ACCESS_SERVICE_BINDER, new TestDataAccessService());
assertThrows(
NullPointerException.class,
() -> {
mBinder.onRequest(
- Constants.OP_EVENT, params, null);
+ Constants.OP_WEB_VIEW_EVENT, params, null);
});
}
@@ -506,9 +506,9 @@
}
}
- @Override public void onEvent(
- EventInput input,
- Consumer<EventOutput> consumer
+ @Override public void onWebViewEvent(
+ WebViewEventInput input,
+ Consumer<WebViewEventOutput> consumer
) {
mOnEventCalled = true;
int eventType = input.getParameters().getInt(EVENT_TYPE_KEY);
@@ -516,7 +516,7 @@
consumer.accept(null);
} else {
consumer.accept(
- new EventOutput.Builder()
+ new WebViewEventOutput.Builder()
.setEventLogRecord(
new EventLogRecord.Builder()
.setType(1)
diff --git a/tests/frameworktests/src/android/ondevicepersonalization/OnDevicePersonalizationFrameworkClassesTest.java b/tests/frameworktests/src/android/ondevicepersonalization/OnDevicePersonalizationFrameworkClassesTest.java
index d8573a5..607fcb1 100644
--- a/tests/frameworktests/src/android/ondevicepersonalization/OnDevicePersonalizationFrameworkClassesTest.java
+++ b/tests/frameworktests/src/android/ondevicepersonalization/OnDevicePersonalizationFrameworkClassesTest.java
@@ -94,16 +94,16 @@
}
/**
- * Tests that the EventInput object serializes correctly.
+ * Tests that the WebViewEventInput object serializes correctly.
*/
@Test
- public void testEventInput() {
+ public void testWebViewEventInput() {
PersistableBundle params = new PersistableBundle();
params.putInt("x", 3);
ArrayList<ContentValues> rows = new ArrayList<>();
rows.add(new ContentValues());
rows.get(0).put("a", 5);
- EventInput result = new EventInput.Builder()
+ WebViewEventInput result = new WebViewEventInput.Builder()
.setParameters(params)
.setRequestLogRecord(
new RequestLogRecord.Builder()
@@ -114,7 +114,7 @@
Parcel parcel = Parcel.obtain();
result.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
- EventInput result2 = EventInput.CREATOR.createFromParcel(parcel);
+ WebViewEventInput result2 = WebViewEventInput.CREATOR.createFromParcel(parcel);
assertEquals(3, result2.getParameters().getInt("x"));
assertEquals(
@@ -122,13 +122,13 @@
}
/**
- * Tests that the Metrics object serializes correctly.
+ * Tests that the WebViewEventOutput object serializes correctly.
*/
@Test
- public void testEventOutput() {
+ public void testWebViewEventOutput() {
ContentValues data = new ContentValues();
data.put("a", 3);
- EventOutput result = new EventOutput.Builder()
+ WebViewEventOutput result = new WebViewEventOutput.Builder()
.setEventLogRecord(
new EventLogRecord.Builder()
.setType(5)
@@ -140,7 +140,7 @@
Parcel parcel = Parcel.obtain();
result.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
- EventOutput result2 = EventOutput.CREATOR.createFromParcel(parcel);
+ WebViewEventOutput result2 = WebViewEventOutput.CREATOR.createFromParcel(parcel);
assertEquals(result, result2);
assertEquals(5, result2.getEventLogRecord().getType());
diff --git a/tests/servicetests/src/com/test/TestPersonalizationHandler.java b/tests/servicetests/src/com/test/TestPersonalizationHandler.java
index 2278e42..2c76fbc 100644
--- a/tests/servicetests/src/com/test/TestPersonalizationHandler.java
+++ b/tests/servicetests/src/com/test/TestPersonalizationHandler.java
@@ -20,9 +20,7 @@
import android.content.ContentValues;
import android.ondevicepersonalization.DownloadInput;
import android.ondevicepersonalization.DownloadOutput;
-import android.ondevicepersonalization.EventInput;
import android.ondevicepersonalization.EventLogRecord;
-import android.ondevicepersonalization.EventOutput;
import android.ondevicepersonalization.ExecuteInput;
import android.ondevicepersonalization.ExecuteOutput;
import android.ondevicepersonalization.IsolatedComputationCallback;
@@ -31,6 +29,8 @@
import android.ondevicepersonalization.RenderOutput;
import android.ondevicepersonalization.RenderingData;
import android.ondevicepersonalization.RequestLogRecord;
+import android.ondevicepersonalization.WebViewEventInput;
+import android.ondevicepersonalization.WebViewEventOutput;
import android.util.Log;
import java.util.ArrayList;
@@ -103,9 +103,9 @@
consumer.accept(result);
}
- public void onEvent(
- @NonNull EventInput input,
- @NonNull Consumer<EventOutput> consumer
+ public void onWebViewEvent(
+ @NonNull WebViewEventInput input,
+ @NonNull Consumer<WebViewEventOutput> consumer
) {
Log.d(TAG, "onEvent() started.");
long longValue = 0;
@@ -114,8 +114,8 @@
}
ContentValues logData = new ContentValues();
logData.put("x", longValue);
- EventOutput result =
- new EventOutput.Builder()
+ WebViewEventOutput result =
+ new WebViewEventOutput.Builder()
.setEventLogRecord(
new EventLogRecord.Builder()
.setType(1)