Merge "Send autofill assist structure data to content capture"
This commit is contained in:
committed by
Android (Google) Code Review
commit
cceb2c2e61
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -424,6 +424,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
suggestionsRequest);
|
||||
}
|
||||
|
||||
if (mActivityToken != null) {
|
||||
mService.sendActivityAssistDataToContentCapture(mActivityToken, resultData);
|
||||
}
|
||||
mRemoteFillService.onFillRequest(request);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user