Merge "Pass augmented client state to the event history." into rvc-dev
This commit is contained in:
@@ -31,6 +31,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.CancellationSignal;
|
import android.os.CancellationSignal;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@@ -558,9 +559,10 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reportResult(@Nullable List<Dataset> inlineSuggestionsData) {
|
void reportResult(@Nullable List<Dataset> inlineSuggestionsData,
|
||||||
|
@Nullable Bundle clientState) {
|
||||||
try {
|
try {
|
||||||
mCallback.onSuccess(inlineSuggestionsData);
|
mCallback.onSuccess(inlineSuggestionsData, clientState);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Error calling back with the inline suggestions data: " + e);
|
Log.e(TAG, "Error calling back with the inline suggestions data: " + e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import android.annotation.NonNull;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.annotation.TestApi;
|
import android.annotation.TestApi;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.service.autofill.Dataset;
|
import android.service.autofill.Dataset;
|
||||||
import android.service.autofill.augmented.AugmentedAutofillService.AutofillProxy;
|
import android.service.autofill.augmented.AugmentedAutofillService.AutofillProxy;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -55,14 +56,15 @@ public final class FillCallback {
|
|||||||
|
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
mProxy.logEvent(AutofillProxy.REPORT_EVENT_NO_RESPONSE);
|
mProxy.logEvent(AutofillProxy.REPORT_EVENT_NO_RESPONSE);
|
||||||
mProxy.reportResult(/* inlineSuggestionsData */ null);
|
mProxy.reportResult(/* inlineSuggestionsData */ null, /* clientState */ null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Dataset> inlineSuggestions = response.getInlineSuggestions();
|
List<Dataset> inlineSuggestions = response.getInlineSuggestions();
|
||||||
|
Bundle clientState = response.getClientState();
|
||||||
if (inlineSuggestions != null && !inlineSuggestions.isEmpty()) {
|
if (inlineSuggestions != null && !inlineSuggestions.isEmpty()) {
|
||||||
mProxy.logEvent(AutofillProxy.REPORT_EVENT_INLINE_RESPONSE);
|
mProxy.logEvent(AutofillProxy.REPORT_EVENT_INLINE_RESPONSE);
|
||||||
mProxy.reportResult(inlineSuggestions);
|
mProxy.reportResult(inlineSuggestions, clientState);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
interface IFillCallback {
|
interface IFillCallback {
|
||||||
void onCancellable(in ICancellationSignal cancellation);
|
void onCancellable(in ICancellationSignal cancellation);
|
||||||
void onSuccess(in @nullable List<Dataset> inlineSuggestionsData);
|
void onSuccess(in @nullable List<Dataset> inlineSuggestionsData, in @nullable Bundle clientState);
|
||||||
boolean isCompleted();
|
boolean isCompleted();
|
||||||
void cancel();
|
void cancel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -815,26 +815,27 @@ final class AutofillManagerServiceImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void logAugmentedAutofillSelected(int sessionId, @Nullable String suggestionId) {
|
void logAugmentedAutofillSelected(int sessionId, @Nullable String suggestionId,
|
||||||
|
@Nullable Bundle clientState) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mAugmentedAutofillEventHistory == null
|
if (mAugmentedAutofillEventHistory == null
|
||||||
|| mAugmentedAutofillEventHistory.getSessionId() != sessionId) {
|
|| mAugmentedAutofillEventHistory.getSessionId() != sessionId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mAugmentedAutofillEventHistory.addEvent(
|
mAugmentedAutofillEventHistory.addEvent(
|
||||||
new Event(Event.TYPE_DATASET_SELECTED, suggestionId, null, null, null,
|
new Event(Event.TYPE_DATASET_SELECTED, suggestionId, clientState, null, null,
|
||||||
null, null, null, null, null, null));
|
null, null, null, null, null, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void logAugmentedAutofillShown(int sessionId) {
|
void logAugmentedAutofillShown(int sessionId, @Nullable Bundle clientState) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mAugmentedAutofillEventHistory == null
|
if (mAugmentedAutofillEventHistory == null
|
||||||
|| mAugmentedAutofillEventHistory.getSessionId() != sessionId) {
|
|| mAugmentedAutofillEventHistory.getSessionId() != sessionId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mAugmentedAutofillEventHistory.addEvent(
|
mAugmentedAutofillEventHistory.addEvent(
|
||||||
new Event(Event.TYPE_DATASETS_SHOWN, null, null, null, null, null,
|
new Event(Event.TYPE_DATASETS_SHOWN, null, clientState, null, null, null,
|
||||||
null, null, null, null, null));
|
null, null, null, null, null));
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1185,15 +1186,16 @@ final class AutofillManagerServiceImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logAugmentedAutofillShown(int sessionId) {
|
public void logAugmentedAutofillShown(int sessionId, Bundle clientState) {
|
||||||
AutofillManagerServiceImpl.this.logAugmentedAutofillShown(sessionId);
|
AutofillManagerServiceImpl.this.logAugmentedAutofillShown(sessionId,
|
||||||
|
clientState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logAugmentedAutofillSelected(int sessionId,
|
public void logAugmentedAutofillSelected(int sessionId,
|
||||||
String suggestionId) {
|
String suggestionId, Bundle clientState) {
|
||||||
AutofillManagerServiceImpl.this.logAugmentedAutofillSelected(sessionId,
|
AutofillManagerServiceImpl.this.logAugmentedAutofillSelected(sessionId,
|
||||||
suggestionId);
|
suggestionId, clientState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -168,12 +168,12 @@ final class RemoteAugmentedAutofillService
|
|||||||
focusedId, focusedValue, requestTime, inlineSuggestionsRequest,
|
focusedId, focusedValue, requestTime, inlineSuggestionsRequest,
|
||||||
new IFillCallback.Stub() {
|
new IFillCallback.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(
|
public void onSuccess(@Nullable List<Dataset> inlineSuggestionsData,
|
||||||
@Nullable List<Dataset> inlineSuggestionsData) {
|
@Nullable Bundle clientState) {
|
||||||
mCallbacks.resetLastResponse();
|
mCallbacks.resetLastResponse();
|
||||||
maybeRequestShowInlineSuggestions(sessionId,
|
maybeRequestShowInlineSuggestions(sessionId,
|
||||||
inlineSuggestionsRequest, inlineSuggestionsData,
|
inlineSuggestionsRequest, inlineSuggestionsData,
|
||||||
focusedId, inlineSuggestionsCallback,
|
clientState, focusedId, inlineSuggestionsCallback,
|
||||||
client, onErrorCallback, remoteRenderService);
|
client, onErrorCallback, remoteRenderService);
|
||||||
requestAutofill.complete(null);
|
requestAutofill.complete(null);
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,8 @@ final class RemoteAugmentedAutofillService
|
|||||||
|
|
||||||
private void maybeRequestShowInlineSuggestions(int sessionId,
|
private void maybeRequestShowInlineSuggestions(int sessionId,
|
||||||
@Nullable InlineSuggestionsRequest request,
|
@Nullable InlineSuggestionsRequest request,
|
||||||
@Nullable List<Dataset> inlineSuggestionsData, @NonNull AutofillId focusedId,
|
@Nullable List<Dataset> inlineSuggestionsData, @Nullable Bundle clientState,
|
||||||
|
@NonNull AutofillId focusedId,
|
||||||
@Nullable Function<InlineSuggestionsResponse, Boolean> inlineSuggestionsCallback,
|
@Nullable Function<InlineSuggestionsResponse, Boolean> inlineSuggestionsCallback,
|
||||||
@NonNull IAutoFillManagerClient client, @NonNull Runnable onErrorCallback,
|
@NonNull IAutoFillManagerClient client, @NonNull Runnable onErrorCallback,
|
||||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
||||||
@@ -256,7 +257,7 @@ final class RemoteAugmentedAutofillService
|
|||||||
@Override
|
@Override
|
||||||
public void autofill(Dataset dataset) {
|
public void autofill(Dataset dataset) {
|
||||||
mCallbacks.logAugmentedAutofillSelected(sessionId,
|
mCallbacks.logAugmentedAutofillSelected(sessionId,
|
||||||
dataset.getId());
|
dataset.getId(), clientState);
|
||||||
try {
|
try {
|
||||||
final ArrayList<AutofillId> fieldIds = dataset.getFieldIds();
|
final ArrayList<AutofillId> fieldIds = dataset.getFieldIds();
|
||||||
final int size = fieldIds.size();
|
final int size = fieldIds.size();
|
||||||
@@ -287,7 +288,7 @@ final class RemoteAugmentedAutofillService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (inlineSuggestionsCallback.apply(inlineSuggestionsResponse)) {
|
if (inlineSuggestionsCallback.apply(inlineSuggestionsResponse)) {
|
||||||
mCallbacks.logAugmentedAutofillShown(sessionId);
|
mCallbacks.logAugmentedAutofillShown(sessionId, clientState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,8 +311,9 @@ final class RemoteAugmentedAutofillService
|
|||||||
|
|
||||||
void setLastResponse(int sessionId);
|
void setLastResponse(int sessionId);
|
||||||
|
|
||||||
void logAugmentedAutofillShown(int sessionId);
|
void logAugmentedAutofillShown(int sessionId, @Nullable Bundle clientState);
|
||||||
|
|
||||||
void logAugmentedAutofillSelected(int sessionId, @Nullable String suggestionId);
|
void logAugmentedAutofillSelected(int sessionId, @Nullable String suggestionId,
|
||||||
|
@Nullable Bundle clientState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user