summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2017-08-31 22:59:02 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-08-31 22:59:02 +0000
commit47f4cbdf046abe0fd5a237b2798cf6ee5a3ddd12 (patch)
tree34ddaea405a7c685afa5dc5798042ed547728cfc
parent54497611f7aa7474c98d1849401b9b9d3dda9a3f (diff)
parent1c501ebfec42eed5abefdb3b21b45f2f253f7a64 (diff)
Merge "Added getClientState() to FillEvent; deprecated it on FillEventHistory."
-rw-r--r--api/current.txt3
-rw-r--r--api/system-current.txt3
-rw-r--r--api/test-current.txt3
-rw-r--r--core/java/android/service/autofill/FillEventHistory.java27
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java21
-rw-r--r--services/autofill/java/com/android/server/autofill/Session.java8
6 files changed, 46 insertions, 19 deletions
diff --git a/api/current.txt b/api/current.txt
index 1b7e7d4b6e94..23a03940c3ab 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -37082,13 +37082,14 @@ package android.service.autofill {
public final class FillEventHistory implements android.os.Parcelable {
method public int describeContents();
- method public android.os.Bundle getClientState();
+ method public deprecated android.os.Bundle getClientState();
method public java.util.List<android.service.autofill.FillEventHistory.Event> getEvents();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.autofill.FillEventHistory> CREATOR;
}
public static final class FillEventHistory.Event {
+ method public android.os.Bundle getClientState();
method public java.lang.String getDatasetId();
method public int getType();
field public static final int TYPE_AUTHENTICATION_SELECTED = 2; // 0x2
diff --git a/api/system-current.txt b/api/system-current.txt
index 5e1cf5a158b1..a843e6d30ee8 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -40173,13 +40173,14 @@ package android.service.autofill {
public final class FillEventHistory implements android.os.Parcelable {
method public int describeContents();
- method public android.os.Bundle getClientState();
+ method public deprecated android.os.Bundle getClientState();
method public java.util.List<android.service.autofill.FillEventHistory.Event> getEvents();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.autofill.FillEventHistory> CREATOR;
}
public static final class FillEventHistory.Event {
+ method public android.os.Bundle getClientState();
method public java.lang.String getDatasetId();
method public int getType();
field public static final int TYPE_AUTHENTICATION_SELECTED = 2; // 0x2
diff --git a/api/test-current.txt b/api/test-current.txt
index d20d4b3b3c11..f5b31d10c67b 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -37280,13 +37280,14 @@ package android.service.autofill {
public final class FillEventHistory implements android.os.Parcelable {
method public int describeContents();
- method public android.os.Bundle getClientState();
+ method public deprecated android.os.Bundle getClientState();
method public java.util.List<android.service.autofill.FillEventHistory.Event> getEvents();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.autofill.FillEventHistory> CREATOR;
}
public static final class FillEventHistory.Event {
+ method public android.os.Bundle getClientState();
method public java.lang.String getDatasetId();
method public int getType();
field public static final int TYPE_AUTHENTICATION_SELECTED = 2; // 0x2
diff --git a/core/java/android/service/autofill/FillEventHistory.java b/core/java/android/service/autofill/FillEventHistory.java
index f7dc1c58ade1..60c1c9a7e87a 100644
--- a/core/java/android/service/autofill/FillEventHistory.java
+++ b/core/java/android/service/autofill/FillEventHistory.java
@@ -81,10 +81,13 @@ public final class FillEventHistory implements Parcelable {
/**
* Returns the client state set in the previous {@link FillResponse}.
*
- * <p><b>NOTE: </b>the state is associated with the app that was autofilled in the previous
+ * <p><b>Note: </b>the state is associated with the app that was autofilled in the previous
* {@link AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, FillCallback)}
* , which is not necessary the same app being autofilled now.
+ *
+ * @deprecated use {@link #getEvents()} then {@link Event#getClientState()} instead.
*/
+ @Deprecated
@Nullable public Bundle getClientState() {
return mClientState;
}
@@ -126,7 +129,6 @@ public final class FillEventHistory implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeBundle(mClientState);
-
if (mEvents == null) {
dest.writeInt(0);
} else {
@@ -137,6 +139,7 @@ public final class FillEventHistory implements Parcelable {
Event event = mEvents.get(i);
dest.writeInt(event.getType());
dest.writeString(event.getDatasetId());
+ dest.writeBundle(event.getClientState());
}
}
}
@@ -177,6 +180,7 @@ public final class FillEventHistory implements Parcelable {
@EventIds private final int mEventType;
@Nullable private final String mDatasetId;
+ @Nullable private final Bundle mClientState;
/**
* Returns the type of the event.
@@ -197,18 +201,32 @@ public final class FillEventHistory implements Parcelable {
}
/**
+ * Returns the client state from the {@link FillResponse} used to generate this event.
+ *
+ * <p><b>Note: </b>the state is associated with the app that was autofilled in the previous
+ * {@link
+ * AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, FillCallback)},
+ * which is not necessary the same app being autofilled now.
+ */
+ @Nullable public Bundle getClientState() {
+ return mClientState;
+ }
+
+ /**
* Creates a new event.
*
* @param eventType The type of the event
* @param datasetId The dataset the event was on, or {@code null} if the event was on the
* whole response.
+ * @param clientState The client state associated with the event.
*
* @hide
*/
- public Event(int eventType, String datasetId) {
+ public Event(int eventType, @Nullable String datasetId, @Nullable Bundle clientState) {
mEventType = Preconditions.checkArgumentInRange(eventType, 0, TYPE_SAVE_SHOWN,
"eventType");
mDatasetId = datasetId;
+ mClientState = clientState;
}
}
@@ -220,7 +238,8 @@ public final class FillEventHistory implements Parcelable {
int numEvents = parcel.readInt();
for (int i = 0; i < numEvents; i++) {
- selection.addEvent(new Event(parcel.readInt(), parcel.readString()));
+ selection.addEvent(new Event(parcel.readInt(), parcel.readString(),
+ parcel.readBundle()));
}
return selection;
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
index 20ccee286fbc..2b8b25ef0fb4 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
@@ -522,10 +522,11 @@ final class AutofillManagerServiceImpl {
/**
* Updates the last fill selection when an authentication was selected.
*/
- void setAuthenticationSelected(int sessionId) {
+ void setAuthenticationSelected(int sessionId, @Nullable Bundle clientState) {
synchronized (mLock) {
if (isValidEventLocked("setAuthenticationSelected()", sessionId)) {
- mEventHistory.addEvent(new Event(Event.TYPE_AUTHENTICATION_SELECTED, null));
+ mEventHistory
+ .addEvent(new Event(Event.TYPE_AUTHENTICATION_SELECTED, null, clientState));
}
}
}
@@ -533,11 +534,13 @@ final class AutofillManagerServiceImpl {
/**
* Updates the last fill selection when an dataset authentication was selected.
*/
- void setDatasetAuthenticationSelected(@Nullable String selectedDataset, int sessionId) {
+ void setDatasetAuthenticationSelected(@Nullable String selectedDataset, int sessionId,
+ @Nullable Bundle clientState) {
synchronized (mLock) {
if (isValidEventLocked("setDatasetAuthenticationSelected()", sessionId)) {
mEventHistory.addEvent(
- new Event(Event.TYPE_DATASET_AUTHENTICATION_SELECTED, selectedDataset));
+ new Event(Event.TYPE_DATASET_AUTHENTICATION_SELECTED, selectedDataset,
+ clientState));
}
}
}
@@ -545,10 +548,10 @@ final class AutofillManagerServiceImpl {
/**
* Updates the last fill selection when an save Ui is shown.
*/
- void setSaveShown(int sessionId) {
+ void setSaveShown(int sessionId, @Nullable Bundle clientState) {
synchronized (mLock) {
if (isValidEventLocked("setSaveShown()", sessionId)) {
- mEventHistory.addEvent(new Event(Event.TYPE_SAVE_SHOWN, null));
+ mEventHistory.addEvent(new Event(Event.TYPE_SAVE_SHOWN, null, clientState));
}
}
}
@@ -556,10 +559,12 @@ final class AutofillManagerServiceImpl {
/**
* Updates the last fill response when a dataset was selected.
*/
- void setDatasetSelected(@Nullable String selectedDataset, int sessionId) {
+ void setDatasetSelected(@Nullable String selectedDataset, int sessionId,
+ @Nullable Bundle clientState) {
synchronized (mLock) {
if (isValidEventLocked("setDatasetSelected()", sessionId)) {
- mEventHistory.addEvent(new Event(Event.TYPE_DATASET_SELECTED, selectedDataset));
+ mEventHistory.addEvent(
+ new Event(Event.TYPE_DATASET_SELECTED, selectedDataset, clientState));
}
}
}
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index 95db6039b696..8d9f0aa2f49b 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -597,7 +597,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
getFillContextByRequestIdLocked(requestId).getStructure(), extras);
}
- mService.setAuthenticationSelected(id);
+ mService.setAuthenticationSelected(id, mClientState);
final int authenticationId = AutofillManager.makeAuthenticationId(requestId, datasetIndex);
mHandlerCaller.getHandler().post(() -> startAuthentication(authenticationId,
@@ -970,7 +970,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
}
if (sDebug) Slog.d(TAG, "Good news, everyone! All checks passed, show save UI!");
- mService.setSaveShown(id);
+ mService.setSaveShown(id, mClientState);
final IAutoFillManagerClient client = getClient();
mPendingSaveUi = new PendingUi(mActivityToken);
getUiForShowing().showSaveUi(mService.getServiceLabel(), saveInfo,
@@ -1532,14 +1532,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
}
// Autofill it directly...
if (dataset.getAuthentication() == null) {
- mService.setDatasetSelected(dataset.getId(), id);
+ mService.setDatasetSelected(dataset.getId(), id, mClientState);
autoFillApp(dataset);
return;
}
// ...or handle authentication.
- mService.setDatasetAuthenticationSelected(dataset.getId(), id);
+ mService.setDatasetAuthenticationSelected(dataset.getId(), id, mClientState);
setViewStatesLocked(null, dataset, ViewState.STATE_WAITING_DATASET_AUTH, false);
final Intent fillInIntent = createAuthFillInIntent(
getFillContextByRequestIdLocked(requestId).getStructure(), mClientState);