diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-02-07 18:41:58 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-02-07 18:41:58 +0000 |
| commit | cceb2c2e61e7ff436b99ab3aea690c73ea65b73f (patch) | |
| tree | 6105a3f1984c25934f90d089304229559880a8a1 | |
| parent | 7f99ea08ebea1ded83da80279cd88aac69fce60d (diff) | |
| parent | 4770be2d609868f1a856b38223b95fcd0560b0fc (diff) | |
Merge "Send autofill assist structure data to content capture"
6 files changed, 47 insertions, 10 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index df7198aa2028..17eac7902d15 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -14131,6 +14131,10 @@ package android.view.contentcapture { method public boolean isContentCaptureFeatureEnabled(); } + public abstract class ContentCaptureSession implements java.lang.AutoCloseable { + field public static final int NO_SESSION_ID = 0; // 0x0 + } + public final class ViewNode extends android.app.assist.AssistStructure.ViewNode { method @Nullable public android.view.autofill.AutofillId getParentAutofillId(); } diff --git a/core/java/android/service/contentcapture/ContentCaptureService.java b/core/java/android/service/contentcapture/ContentCaptureService.java index 707426a22889..0edd01330fdd 100644 --- a/core/java/android/service/contentcapture/ContentCaptureService.java +++ b/core/java/android/service/contentcapture/ContentCaptureService.java @@ -345,9 +345,11 @@ public abstract class ContentCaptureService extends Service { } /** - * Notifies the service of {@link SnapshotData snapshot data} associated with a session. + * Notifies the service of {@link SnapshotData snapshot data} associated with an activity. * - * @param sessionId the session's Id + * @param sessionId the session's Id. This may also be + * {@link ContentCaptureSession#NO_SESSION_ID} if no content capture session + * exists for the activity being snapshotted * @param snapshotData the data */ public void onActivitySnapshot(@NonNull ContentCaptureSessionId sessionId, diff --git a/core/java/android/view/contentcapture/ContentCaptureSession.java b/core/java/android/view/contentcapture/ContentCaptureSession.java index 232d96ba7f43..2134dab7986b 100644 --- a/core/java/android/view/contentcapture/ContentCaptureSession.java +++ b/core/java/android/view/contentcapture/ContentCaptureSession.java @@ -22,6 +22,7 @@ import android.annotation.CallSuper; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.SystemApi; import android.util.DebugUtils; import android.util.Log; import android.view.View; @@ -50,7 +51,11 @@ public abstract class ContentCaptureSession implements AutoCloseable { private static final Random sIdGenerator = new Random(); - /** @hide */ + /** + * ID used to indicate that a session does not exist + * @hide + */ + @SystemApi public static final int NO_SESSION_ID = 0; /** diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java index 1cb9313d9bf9..4474f608f955 100644 --- a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java +++ b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java @@ -82,6 +82,7 @@ import com.android.server.LocalServices; import com.android.server.autofill.AutofillManagerService.AutofillCompatState; import com.android.server.autofill.RemoteAugmentedAutofillService.RemoteAugmentedAutofillServiceCallbacks; import com.android.server.autofill.ui.AutoFillUI; +import com.android.server.contentcapture.ContentCaptureManagerInternal; import com.android.server.infra.AbstractPerUserSystemService; import com.android.server.inputmethod.InputMethodManagerInternal; @@ -180,6 +181,8 @@ final class AutofillManagerServiceImpl private final InputMethodManagerInternal mInputMethodManagerInternal; + private final ContentCaptureManagerInternal mContentCaptureManagerInternal; + AutofillManagerServiceImpl(AutofillManagerService master, Object lock, LocalLog uiLatencyHistory, LocalLog wtfHistory, int userId, AutoFillUI ui, AutofillCompatState autofillCompatState, @@ -192,10 +195,22 @@ final class AutofillManagerServiceImpl mFieldClassificationStrategy = new FieldClassificationStrategy(getContext(), userId); mAutofillCompatState = autofillCompatState; mInputMethodManagerInternal = LocalServices.getService(InputMethodManagerInternal.class); + mContentCaptureManagerInternal = LocalServices.getService( + ContentCaptureManagerInternal.class); updateLocked(disabled); } + boolean sendActivityAssistDataToContentCapture(@NonNull IBinder activityToken, + @NonNull Bundle data) { + if (mContentCaptureManagerInternal != null) { + mContentCaptureManagerInternal.sendActivityAssistData(getUserId(), activityToken, data); + return true; + } + + return false; + } + @GuardedBy("mLock") void onBackKeyPressed() { final RemoteAugmentedAutofillService remoteService = diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 2fc116e504ee..a25d7353edcb 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -424,6 +424,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState suggestionsRequest); } + if (mActivityToken != null) { + mService.sendActivityAssistDataToContentCapture(mActivityToken, resultData); + } mRemoteFillService.onFillRequest(request); } diff --git a/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java b/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java index 583c5b593b88..32bca35009a8 100644 --- a/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java +++ b/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java @@ -426,18 +426,26 @@ final class ContentCapturePerUserService public boolean sendActivityAssistDataLocked(@NonNull IBinder activityToken, @NonNull Bundle data) { final int id = getSessionId(activityToken); + final Bundle assistData = data.getBundle(ASSIST_KEY_DATA); + final AssistStructure assistStructure = data.getParcelable(ASSIST_KEY_STRUCTURE); + final AssistContent assistContent = data.getParcelable(ASSIST_KEY_CONTENT); + final SnapshotData snapshotData = new SnapshotData(assistData, + assistStructure, assistContent); if (id != NO_SESSION_ID) { final ContentCaptureServerSession session = mSessions.get(id); - final Bundle assistData = data.getBundle(ASSIST_KEY_DATA); - final AssistStructure assistStructure = data.getParcelable(ASSIST_KEY_STRUCTURE); - final AssistContent assistContent = data.getParcelable(ASSIST_KEY_CONTENT); - final SnapshotData snapshotData = new SnapshotData(assistData, - assistStructure, assistContent); session.sendActivitySnapshotLocked(snapshotData); return true; - } else { - Slog.e(TAG, "Failed to notify activity assist data for activity: " + activityToken); } + + // We want to send an activity snapshot regardless of whether a content capture session is + // present or not since a content capture session is not required for this functionality + if (mRemoteService != null) { + mRemoteService.onActivitySnapshotRequest(NO_SESSION_ID, snapshotData); + Slog.d(TAG, "Notified activity assist data for activity: " + + activityToken + " without a session Id"); + return true; + } + return false; } |
