Loading api/current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -52228,7 +52228,6 @@ package android.view.contentcapture { } public final class ContentCaptureManager { method public android.view.contentcapture.ContentCaptureSession createContentCaptureSession(android.view.contentcapture.ContentCaptureContext); method public android.content.ComponentName getServiceComponentName(); method public boolean isContentCaptureEnabled(); method public void removeUserData(android.view.contentcapture.UserDataRemovalRequest); Loading @@ -52237,6 +52236,7 @@ package android.view.contentcapture { public abstract class ContentCaptureSession implements java.lang.AutoCloseable { method public void close(); method public final android.view.contentcapture.ContentCaptureSession createContentCaptureSession(android.view.contentcapture.ContentCaptureContext); method public final void destroy(); method public final android.view.contentcapture.ContentCaptureSessionId getContentCaptureSessionId(); method public final void notifyViewAppeared(android.view.ViewStructure); api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -7570,6 +7570,7 @@ package android.view.contentcapture { method public int getDisplayId(); method public android.os.Bundle getExtras(); method public int getFlags(); method public android.view.contentcapture.ContentCaptureSessionId getParentSessionId(); method public int getTaskId(); method public android.net.Uri getUri(); field public static final int FLAG_DISABLED_BY_APP = 1; // 0x1 Loading core/java/android/service/contentcapture/ContentCaptureService.java +28 −6 Original line number Diff line number Diff line Loading @@ -34,13 +34,13 @@ import android.os.RemoteException; import android.util.ArrayMap; import android.util.Log; import android.util.Slog; import android.view.contentcapture.ActivityContentCaptureSession; import android.view.contentcapture.ContentCaptureContext; import android.view.contentcapture.ContentCaptureEvent; import android.view.contentcapture.ContentCaptureManager; import android.view.contentcapture.ContentCaptureSession; import android.view.contentcapture.ContentCaptureSessionId; import android.view.contentcapture.IContentCaptureDirectManager; import android.view.contentcapture.MainContentCaptureSession; import com.android.internal.os.IResultReceiver; Loading Loading @@ -293,15 +293,28 @@ public abstract class ContentCaptureService extends Service { final List<ContentCaptureEvent> events = parceledEvents.getList(); for (int i = 0; i < events.size(); i++) { final ContentCaptureEvent event = events.get(i); if (!handleIsRightCallerFor(event, uid)) continue; String sessionIdString = event.getSessionId(); if (!sessionIdString.equals(lastSessionId)) { if (!handleIsRightCallerFor(sessionIdString, uid)) continue; sessionId = new ContentCaptureSessionId(sessionIdString); lastSessionId = sessionIdString; } switch (event.getType()) { case ContentCaptureEvent.TYPE_SESSION_STARTED: final ContentCaptureContext clientContext = event.getClientContext(); clientContext.setParentSessionId(event.getParentSessionId()); mSessionsByUid.put(sessionIdString, uid); onCreateContentCaptureSession(clientContext, sessionId); break; case ContentCaptureEvent.TYPE_SESSION_FINISHED: mSessionsByUid.remove(sessionIdString); onDestroyContentCaptureSession(sessionId); break; default: onContentCaptureEvent(sessionId, event); } } } private void handleOnActivitySnapshot(@NonNull String sessionId, @NonNull SnapshotData snapshotData) { Loading @@ -314,9 +327,18 @@ public abstract class ContentCaptureService extends Service { } /** * Checks if the given {@code uid} owns the session. * Checks if the given {@code uid} owns the session associated with the event. */ private boolean handleIsRightCallerFor(@NonNull String sessionId, int uid) { private boolean handleIsRightCallerFor(@NonNull ContentCaptureEvent event, int uid) { final String sessionId; switch (event.getType()) { case ContentCaptureEvent.TYPE_SESSION_STARTED: case ContentCaptureEvent.TYPE_SESSION_FINISHED: sessionId = event.getParentSessionId(); break; default: sessionId = event.getSessionId(); } final Integer rightUid = mSessionsByUid.get(sessionId); if (rightUid == null) { if (VERBOSE) Log.v(TAG, "No session for " + sessionId); Loading Loading @@ -347,7 +369,7 @@ public abstract class ContentCaptureService extends Service { final Bundle extras; if (binder != null) { extras = new Bundle(); extras.putBinder(ActivityContentCaptureSession.EXTRA_BINDER, binder); extras.putBinder(MainContentCaptureSession.EXTRA_BINDER, binder); } else { extras = null; } Loading core/java/android/view/View.java +5 −6 Original line number Diff line number Diff line Loading @@ -9046,17 +9046,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * {@code onCreate()} and associate it with the root view of the activity: * * <pre> * ContentCaptureManager mgr = getSystemService(ContentCaptureManager.class); * if (mgr != null && mgr.isContentCaptureEnabled()) { * View rootView = findViewById(R.my_root_view); * ContentCaptureSession session = mgr.createContentCaptureSession(new * ContentCaptureSession oldSession = rootView.getContentCaptureSession(); * if (oldSession != null) { * ContentCaptureSession newSession = oldSession.createContentCaptureSession(new * ContentCaptureContext.Builder().setUri(myUrl).build()); * rootView.setContentCaptureSession(session); * rootView.setContentCaptureSession(newSession); * } * </pre> * * @param contentCaptureSession a session created by * {@link ContentCaptureManager#createContentCaptureSession( * {@link ContentCaptureSession#createContentCaptureSession( * android.view.contentcapture.ContentCaptureContext)}. */ public void setContentCaptureSession(@NonNull ContentCaptureSession contentCaptureSession) { core/java/android/view/contentcapture/ChildContentCaptureSession.java 0 → 100644 +99 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view.contentcapture; import android.annotation.NonNull; import android.annotation.Nullable; import android.view.autofill.AutofillId; import android.view.contentcapture.ViewNode.ViewStructureImpl; import com.android.internal.util.Preconditions; import java.io.PrintWriter; /** * A session that is explicitly created by the app (and hence is a descendant of * {@link MainContentCaptureSession}). * * @hide */ final class ChildContentCaptureSession extends ContentCaptureSession { @NonNull private final MainContentCaptureSession mParent; /** * {@link ContentCaptureContext} set by client, or {@code null} when it's the * {@link ContentCaptureManager#getMainContentCaptureSession() default session} for the * context. * * @hide */ @NonNull private final ContentCaptureContext mClientContext; /** @hide */ protected ChildContentCaptureSession(@NonNull MainContentCaptureSession parent, @NonNull ContentCaptureContext clientContext) { mParent = parent; mClientContext = Preconditions.checkNotNull(clientContext); } @Override ContentCaptureSession newChild(@NonNull ContentCaptureContext context) { // TODO(b/121033016): implement it throw new UnsupportedOperationException("grand-children not implemented yet"); } @Override void flush() { mParent.flush(); } @Override void onDestroy() { mParent.notifyChildSessionFinished(mParent.mId, mId); } @Override void internalNotifyViewAppeared(@NonNull ViewStructureImpl node) { mParent.notifyViewAppeared(mId, node); } @Override void internalNotifyViewDisappeared(@NonNull AutofillId id) { mParent.notifyViewDisappeared(mId, id); } @Override void internalNotifyViewTextChanged(@NonNull AutofillId id, @Nullable CharSequence text, int flags) { mParent.notifyViewTextChanged(mId, id, text, flags); } @Override boolean isContentCaptureEnabled() { return mParent.isContentCaptureEnabled(); } @Override void dump(String prefix, PrintWriter pw) { if (mClientContext != null) { // NOTE: we don't dump clientContent because it could have PII pw.print(prefix); pw.println("hasClientContext"); } super.dump(prefix, pw); } } Loading
api/current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -52228,7 +52228,6 @@ package android.view.contentcapture { } public final class ContentCaptureManager { method public android.view.contentcapture.ContentCaptureSession createContentCaptureSession(android.view.contentcapture.ContentCaptureContext); method public android.content.ComponentName getServiceComponentName(); method public boolean isContentCaptureEnabled(); method public void removeUserData(android.view.contentcapture.UserDataRemovalRequest); Loading @@ -52237,6 +52236,7 @@ package android.view.contentcapture { public abstract class ContentCaptureSession implements java.lang.AutoCloseable { method public void close(); method public final android.view.contentcapture.ContentCaptureSession createContentCaptureSession(android.view.contentcapture.ContentCaptureContext); method public final void destroy(); method public final android.view.contentcapture.ContentCaptureSessionId getContentCaptureSessionId(); method public final void notifyViewAppeared(android.view.ViewStructure);
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -7570,6 +7570,7 @@ package android.view.contentcapture { method public int getDisplayId(); method public android.os.Bundle getExtras(); method public int getFlags(); method public android.view.contentcapture.ContentCaptureSessionId getParentSessionId(); method public int getTaskId(); method public android.net.Uri getUri(); field public static final int FLAG_DISABLED_BY_APP = 1; // 0x1 Loading
core/java/android/service/contentcapture/ContentCaptureService.java +28 −6 Original line number Diff line number Diff line Loading @@ -34,13 +34,13 @@ import android.os.RemoteException; import android.util.ArrayMap; import android.util.Log; import android.util.Slog; import android.view.contentcapture.ActivityContentCaptureSession; import android.view.contentcapture.ContentCaptureContext; import android.view.contentcapture.ContentCaptureEvent; import android.view.contentcapture.ContentCaptureManager; import android.view.contentcapture.ContentCaptureSession; import android.view.contentcapture.ContentCaptureSessionId; import android.view.contentcapture.IContentCaptureDirectManager; import android.view.contentcapture.MainContentCaptureSession; import com.android.internal.os.IResultReceiver; Loading Loading @@ -293,15 +293,28 @@ public abstract class ContentCaptureService extends Service { final List<ContentCaptureEvent> events = parceledEvents.getList(); for (int i = 0; i < events.size(); i++) { final ContentCaptureEvent event = events.get(i); if (!handleIsRightCallerFor(event, uid)) continue; String sessionIdString = event.getSessionId(); if (!sessionIdString.equals(lastSessionId)) { if (!handleIsRightCallerFor(sessionIdString, uid)) continue; sessionId = new ContentCaptureSessionId(sessionIdString); lastSessionId = sessionIdString; } switch (event.getType()) { case ContentCaptureEvent.TYPE_SESSION_STARTED: final ContentCaptureContext clientContext = event.getClientContext(); clientContext.setParentSessionId(event.getParentSessionId()); mSessionsByUid.put(sessionIdString, uid); onCreateContentCaptureSession(clientContext, sessionId); break; case ContentCaptureEvent.TYPE_SESSION_FINISHED: mSessionsByUid.remove(sessionIdString); onDestroyContentCaptureSession(sessionId); break; default: onContentCaptureEvent(sessionId, event); } } } private void handleOnActivitySnapshot(@NonNull String sessionId, @NonNull SnapshotData snapshotData) { Loading @@ -314,9 +327,18 @@ public abstract class ContentCaptureService extends Service { } /** * Checks if the given {@code uid} owns the session. * Checks if the given {@code uid} owns the session associated with the event. */ private boolean handleIsRightCallerFor(@NonNull String sessionId, int uid) { private boolean handleIsRightCallerFor(@NonNull ContentCaptureEvent event, int uid) { final String sessionId; switch (event.getType()) { case ContentCaptureEvent.TYPE_SESSION_STARTED: case ContentCaptureEvent.TYPE_SESSION_FINISHED: sessionId = event.getParentSessionId(); break; default: sessionId = event.getSessionId(); } final Integer rightUid = mSessionsByUid.get(sessionId); if (rightUid == null) { if (VERBOSE) Log.v(TAG, "No session for " + sessionId); Loading Loading @@ -347,7 +369,7 @@ public abstract class ContentCaptureService extends Service { final Bundle extras; if (binder != null) { extras = new Bundle(); extras.putBinder(ActivityContentCaptureSession.EXTRA_BINDER, binder); extras.putBinder(MainContentCaptureSession.EXTRA_BINDER, binder); } else { extras = null; } Loading
core/java/android/view/View.java +5 −6 Original line number Diff line number Diff line Loading @@ -9046,17 +9046,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * {@code onCreate()} and associate it with the root view of the activity: * * <pre> * ContentCaptureManager mgr = getSystemService(ContentCaptureManager.class); * if (mgr != null && mgr.isContentCaptureEnabled()) { * View rootView = findViewById(R.my_root_view); * ContentCaptureSession session = mgr.createContentCaptureSession(new * ContentCaptureSession oldSession = rootView.getContentCaptureSession(); * if (oldSession != null) { * ContentCaptureSession newSession = oldSession.createContentCaptureSession(new * ContentCaptureContext.Builder().setUri(myUrl).build()); * rootView.setContentCaptureSession(session); * rootView.setContentCaptureSession(newSession); * } * </pre> * * @param contentCaptureSession a session created by * {@link ContentCaptureManager#createContentCaptureSession( * {@link ContentCaptureSession#createContentCaptureSession( * android.view.contentcapture.ContentCaptureContext)}. */ public void setContentCaptureSession(@NonNull ContentCaptureSession contentCaptureSession) {
core/java/android/view/contentcapture/ChildContentCaptureSession.java 0 → 100644 +99 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view.contentcapture; import android.annotation.NonNull; import android.annotation.Nullable; import android.view.autofill.AutofillId; import android.view.contentcapture.ViewNode.ViewStructureImpl; import com.android.internal.util.Preconditions; import java.io.PrintWriter; /** * A session that is explicitly created by the app (and hence is a descendant of * {@link MainContentCaptureSession}). * * @hide */ final class ChildContentCaptureSession extends ContentCaptureSession { @NonNull private final MainContentCaptureSession mParent; /** * {@link ContentCaptureContext} set by client, or {@code null} when it's the * {@link ContentCaptureManager#getMainContentCaptureSession() default session} for the * context. * * @hide */ @NonNull private final ContentCaptureContext mClientContext; /** @hide */ protected ChildContentCaptureSession(@NonNull MainContentCaptureSession parent, @NonNull ContentCaptureContext clientContext) { mParent = parent; mClientContext = Preconditions.checkNotNull(clientContext); } @Override ContentCaptureSession newChild(@NonNull ContentCaptureContext context) { // TODO(b/121033016): implement it throw new UnsupportedOperationException("grand-children not implemented yet"); } @Override void flush() { mParent.flush(); } @Override void onDestroy() { mParent.notifyChildSessionFinished(mParent.mId, mId); } @Override void internalNotifyViewAppeared(@NonNull ViewStructureImpl node) { mParent.notifyViewAppeared(mId, node); } @Override void internalNotifyViewDisappeared(@NonNull AutofillId id) { mParent.notifyViewDisappeared(mId, id); } @Override void internalNotifyViewTextChanged(@NonNull AutofillId id, @Nullable CharSequence text, int flags) { mParent.notifyViewTextChanged(mId, id, text, flags); } @Override boolean isContentCaptureEnabled() { return mParent.isContentCaptureEnabled(); } @Override void dump(String prefix, PrintWriter pw) { if (mClientContext != null) { // NOTE: we don't dump clientContent because it could have PII pw.print(prefix); pw.println("hasClientContext"); } super.dump(prefix, pw); } }