summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/service/autofill/augmented/AugmentedAutofillService.java35
-rw-r--r--core/java/android/service/autofill/augmented/FillCallback.java2
-rw-r--r--core/java/android/service/autofill/augmented/FillResponse.java56
-rw-r--r--core/java/android/service/autofill/augmented/IFillCallback.aidl3
4 files changed, 85 insertions, 11 deletions
diff --git a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java
index 6334d9d765c8..368c94cdc790 100644
--- a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java
+++ b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java
@@ -31,6 +31,7 @@ import android.content.ComponentName;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Build;
+import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.IBinder;
@@ -39,6 +40,7 @@ import android.os.Looper;
import android.os.RemoteException;
import android.os.SystemClock;
import android.service.autofill.Dataset;
+import android.service.autofill.FillEventHistory;
import android.service.autofill.augmented.PresentationParams.SystemPopupPresentationParams;
import android.util.Log;
import android.util.Pair;
@@ -319,6 +321,31 @@ public abstract class AugmentedAutofillService extends Service {
pw.print(getClass().getName()); pw.println(": nothing to dump");
}
+ /**
+ * Gets the inline augmented autofill events that happened after the last
+ * {@link #onFillRequest(FillRequest, CancellationSignal, FillController, FillCallback)} call.
+ *
+ * <p>The history is not persisted over reboots, and it's cleared every time the service
+ * replies to a
+ * {@link #onFillRequest(FillRequest, CancellationSignal, FillController, FillCallback)}
+ * by calling {@link FillCallback#onSuccess(FillResponse)}. Hence, the service should call
+ * {@link #getFillEventHistory() before finishing the {@link FillCallback}.
+ *
+ * <p>Also note that the events from the dropdown suggestion UI is not stored in the history
+ * since the service owns the UI.
+ *
+ * @return The history or {@code null} if there are no events.
+ */
+ @Nullable public final FillEventHistory getFillEventHistory() {
+ final AutofillManager afm = getSystemService(AutofillManager.class);
+
+ if (afm == null) {
+ return null;
+ } else {
+ return afm.getFillEventHistory();
+ }
+ }
+
/** @hide */
static final class AutofillProxy {
@@ -487,9 +514,10 @@ public abstract class AugmentedAutofillService extends Service {
}
}
- public void onInlineSuggestionsDataReady(@NonNull List<Dataset> inlineSuggestionsData) {
+ public void onInlineSuggestionsDataReady(@NonNull List<Dataset> inlineSuggestionsData,
+ @Nullable Bundle clientState) {
try {
- mCallback.onSuccess(inlineSuggestionsData.toArray(new Dataset[]{}));
+ mCallback.onSuccess(inlineSuggestionsData.toArray(new Dataset[]{}), clientState);
} catch (RemoteException e) {
Log.e(TAG, "Error calling back with the inline suggestions data: " + e);
}
@@ -511,7 +539,8 @@ public abstract class AugmentedAutofillService extends Service {
}
}
try {
- mCallback.onSuccess(/* mInlineSuggestionsData= */null);
+ mCallback.onSuccess(/* inlineSuggestionsData= */null, /* clientState=*/
+ null);
} catch (RemoteException e) {
Log.e(TAG, "Error reporting success: " + e);
}
diff --git a/core/java/android/service/autofill/augmented/FillCallback.java b/core/java/android/service/autofill/augmented/FillCallback.java
index b767799847d7..d0ffd7b4d8d4 100644
--- a/core/java/android/service/autofill/augmented/FillCallback.java
+++ b/core/java/android/service/autofill/augmented/FillCallback.java
@@ -60,7 +60,7 @@ public final class FillCallback {
List<Dataset> inlineSuggestions = response.getInlineSuggestions();
if (inlineSuggestions != null && !inlineSuggestions.isEmpty()) {
- mProxy.onInlineSuggestionsDataReady(inlineSuggestions);
+ mProxy.onInlineSuggestionsDataReady(inlineSuggestions, response.getClientState());
return;
}
diff --git a/core/java/android/service/autofill/augmented/FillResponse.java b/core/java/android/service/autofill/augmented/FillResponse.java
index e8e6ff05da03..68ba63ac35a8 100644
--- a/core/java/android/service/autofill/augmented/FillResponse.java
+++ b/core/java/android/service/autofill/augmented/FillResponse.java
@@ -19,6 +19,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.TestApi;
+import android.os.Bundle;
import android.service.autofill.Dataset;
import com.android.internal.util.DataClass;
@@ -50,6 +51,13 @@ public final class FillResponse {
@DataClass.PluralOf("inlineSuggestion")
private @Nullable List<Dataset> mInlineSuggestions;
+ /**
+ * The client state that {@link AugmentedAutofillService} implementation can put anything in to
+ * identify the request and the response when calling
+ * {@link AugmentedAutofillService#getFillEventHistory()}.
+ */
+ private @Nullable Bundle mClientState;
+
private static FillWindow defaultFillWindow() {
return null;
}
@@ -58,6 +66,10 @@ public final class FillResponse {
return null;
}
+ private static Bundle defaultClientState() {
+ return null;
+ }
+
/** @hide */
abstract static class BaseBuilder {
@@ -82,9 +94,11 @@ public final class FillResponse {
@DataClass.Generated.Member
/* package-private */ FillResponse(
@Nullable FillWindow fillWindow,
- @Nullable List<Dataset> inlineSuggestions) {
+ @Nullable List<Dataset> inlineSuggestions,
+ @Nullable Bundle clientState) {
this.mFillWindow = fillWindow;
this.mInlineSuggestions = inlineSuggestions;
+ this.mClientState = clientState;
// onConstructed(); // You can define this method to get a callback
}
@@ -111,6 +125,18 @@ public final class FillResponse {
}
/**
+ * The client state that {@link AugmentedAutofillService} implementation can put anything in to
+ * identify the request and the response when calling
+ * {@link AugmentedAutofillService#getFillEventHistory()}.
+ *
+ * @hide
+ */
+ @DataClass.Generated.Member
+ public @Nullable Bundle getClientState() {
+ return mClientState;
+ }
+
+ /**
* A builder for {@link FillResponse}
*/
@SuppressWarnings("WeakerAccess")
@@ -119,6 +145,7 @@ public final class FillResponse {
private @Nullable FillWindow mFillWindow;
private @Nullable List<Dataset> mInlineSuggestions;
+ private @Nullable Bundle mClientState;
private long mBuilderFieldsSet = 0L;
@@ -157,10 +184,23 @@ public final class FillResponse {
return this;
}
+ /**
+ * The client state that {@link AugmentedAutofillService} implementation can put anything in to
+ * identify the request and the response when calling
+ * {@link AugmentedAutofillService#getFillEventHistory()}.
+ */
+ @DataClass.Generated.Member
+ public @NonNull Builder setClientState(@Nullable Bundle value) {
+ checkNotUsed();
+ mBuilderFieldsSet |= 0x4;
+ mClientState = value;
+ return this;
+ }
+
/** Builds the instance. This builder should not be touched after calling this! */
public @NonNull FillResponse build() {
checkNotUsed();
- mBuilderFieldsSet |= 0x4; // Mark builder used
+ mBuilderFieldsSet |= 0x8; // Mark builder used
if ((mBuilderFieldsSet & 0x1) == 0) {
mFillWindow = defaultFillWindow();
@@ -168,14 +208,18 @@ public final class FillResponse {
if ((mBuilderFieldsSet & 0x2) == 0) {
mInlineSuggestions = defaultInlineSuggestions();
}
+ if ((mBuilderFieldsSet & 0x4) == 0) {
+ mClientState = defaultClientState();
+ }
FillResponse o = new FillResponse(
mFillWindow,
- mInlineSuggestions);
+ mInlineSuggestions,
+ mClientState);
return o;
}
private void checkNotUsed() {
- if ((mBuilderFieldsSet & 0x4) != 0) {
+ if ((mBuilderFieldsSet & 0x8) != 0) {
throw new IllegalStateException(
"This Builder should not be reused. Use a new Builder instance instead");
}
@@ -183,10 +227,10 @@ public final class FillResponse {
}
@DataClass.Generated(
- time = 1577476012370L,
+ time = 1580335256422L,
codegenVersion = "1.0.14",
sourceFile = "frameworks/base/core/java/android/service/autofill/augmented/FillResponse.java",
- inputSignatures = "private @android.annotation.Nullable android.service.autofill.augmented.FillWindow mFillWindow\nprivate @com.android.internal.util.DataClass.PluralOf(\"inlineSuggestion\") @android.annotation.Nullable java.util.List<android.service.autofill.Dataset> mInlineSuggestions\nprivate static android.service.autofill.augmented.FillWindow defaultFillWindow()\nprivate static java.util.List<android.service.autofill.Dataset> defaultInlineSuggestions()\nclass FillResponse extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genBuilder=true, genHiddenGetters=true)\nabstract android.service.autofill.augmented.FillResponse.Builder addInlineSuggestion(android.service.autofill.Dataset)\nclass BaseBuilder extends java.lang.Object implements []")
+ inputSignatures = "private @android.annotation.Nullable android.service.autofill.augmented.FillWindow mFillWindow\nprivate @com.android.internal.util.DataClass.PluralOf(\"inlineSuggestion\") @android.annotation.Nullable java.util.List<android.service.autofill.Dataset> mInlineSuggestions\nprivate @android.annotation.Nullable android.os.Bundle mClientState\nprivate static android.service.autofill.augmented.FillWindow defaultFillWindow()\nprivate static java.util.List<android.service.autofill.Dataset> defaultInlineSuggestions()\nprivate static android.os.Bundle defaultClientState()\nclass FillResponse extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genBuilder=true, genHiddenGetters=true)\nabstract android.service.autofill.augmented.FillResponse.Builder addInlineSuggestion(android.service.autofill.Dataset)\nclass BaseBuilder extends java.lang.Object implements []")
@Deprecated
private void __metadata() {}
diff --git a/core/java/android/service/autofill/augmented/IFillCallback.aidl b/core/java/android/service/autofill/augmented/IFillCallback.aidl
index 3ccb3114a10f..31e77f358782 100644
--- a/core/java/android/service/autofill/augmented/IFillCallback.aidl
+++ b/core/java/android/service/autofill/augmented/IFillCallback.aidl
@@ -16,6 +16,7 @@
package android.service.autofill.augmented;
+import android.os.Bundle;
import android.os.ICancellationSignal;
import android.service.autofill.Dataset;
@@ -27,7 +28,7 @@ import android.service.autofill.Dataset;
*/
interface IFillCallback {
void onCancellable(in ICancellationSignal cancellation);
- void onSuccess(in @nullable Dataset[] mInlineSuggestionsData);
+ void onSuccess(in @nullable Dataset[] inlineSuggestionsData, in @nullable Bundle clientState);
boolean isCompleted();
void cancel();
}