Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78478fcb authored by MingWei Liao's avatar MingWei Liao Committed by Android (Google) Code Review
Browse files

Merge "Decouple direct dependency on MainContentCaptureSession" into main

parents 93873e49 85dc25ce
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ import android.view.contentcapture.ContentCaptureSessionId;
import android.view.contentcapture.DataRemovalRequest;
import android.view.contentcapture.DataShareRequest;
import android.view.contentcapture.IContentCaptureDirectManager;
import android.view.contentcapture.MainContentCaptureSession;

import com.android.internal.os.IResultReceiver;
import com.android.internal.util.FrameworkStatsLog;
@@ -724,7 +723,7 @@ public abstract class ContentCaptureService extends Service {
            final Bundle extras;
            if (binder != null) {
                extras = new Bundle();
                extras.putBinder(MainContentCaptureSession.EXTRA_BINDER, binder);
                extras.putBinder(ContentCaptureSession.EXTRA_BINDER, binder);
            } else {
                extras = null;
            }
+2 −2
Original line number Diff line number Diff line
@@ -10760,11 +10760,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            return;
        }
        session.internalNotifyViewTreeEvent(/* started= */ true);
        session.notifyViewTreeEvent(/* started= */ true);
        try {
            dispatchProvideContentCaptureStructure();
        } finally {
            session.internalNotifyViewTreeEvent(/* started= */ false);
            session.notifyViewTreeEvent(/* started= */ false);
        }
    }
+3 −4
Original line number Diff line number Diff line
@@ -209,7 +209,6 @@ import android.view.animation.Interpolator;
import android.view.autofill.AutofillManager;
import android.view.contentcapture.ContentCaptureManager;
import android.view.contentcapture.ContentCaptureSession;
import android.view.contentcapture.MainContentCaptureSession;
import android.view.inputmethod.ImeTracker;
import android.view.inputmethod.InputMethodManager;
import android.widget.Scroller;
@@ -4103,7 +4102,7 @@ public final class ViewRootImpl implements ViewParent,
        final ContentCaptureManager manager = mAttachInfo.mContentCaptureManager;
        if (manager != null && mAttachInfo.mContentCaptureEvents != null) {
            final MainContentCaptureSession session = manager.getMainContentCaptureSession();
            final ContentCaptureSession session = manager.getMainContentCaptureSession();
            session.notifyContentCaptureEvents(mAttachInfo.mContentCaptureEvents);
        }
        mAttachInfo.mContentCaptureEvents = null;
@@ -5020,7 +5019,7 @@ public final class ViewRootImpl implements ViewParent,
            // Initial dispatch of window bounds to content capture
            if (mAttachInfo.mContentCaptureManager != null) {
                MainContentCaptureSession session =
                ContentCaptureSession session =
                        mAttachInfo.mContentCaptureManager.getMainContentCaptureSession();
                session.notifyWindowBoundsChanged(session.getId(),
                        getConfiguration().windowConfiguration.getBounds());
@@ -8805,7 +8804,7 @@ public final class ViewRootImpl implements ViewParent,
        mSurfaceControl.setTransformHint(transformHint);
        if (mAttachInfo.mContentCaptureManager != null) {
            MainContentCaptureSession mainSession = mAttachInfo.mContentCaptureManager
            ContentCaptureSession mainSession = mAttachInfo.mContentCaptureManager
                    .getMainContentCaptureSession();
            mainSession.notifyWindowBoundsChanged(mainSession.getId(),
                    getConfiguration().windowConfiguration.getBounds());
+67 −16
Original line number Diff line number Diff line
@@ -17,10 +17,16 @@ package android.view.contentcapture;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.ComponentName;
import android.graphics.Insets;
import android.graphics.Rect;
import android.os.IBinder;
import android.util.SparseArray;
import android.view.autofill.AutofillId;
import android.view.contentcapture.ViewNode.ViewStructureImpl;

import java.util.ArrayList;

/**
 * A session that is explicitly created by the app (and hence is a descendant of
 * {@link MainContentCaptureSession}).
@@ -40,17 +46,33 @@ final class ChildContentCaptureSession extends ContentCaptureSession {
    }

    @Override
    MainContentCaptureSession getMainCaptureSession() {
    ContentCaptureSession getMainCaptureSession() {
        if (mParent instanceof MainContentCaptureSession) {
            return (MainContentCaptureSession) mParent;
        }
        return mParent.getMainCaptureSession();
    }

    @Override
    void start(@NonNull IBinder token, @NonNull IBinder shareableActivityToken,
            @NonNull ComponentName component, int flags) {
        getMainCaptureSession().start(token, shareableActivityToken, component, flags);
    }

    @Override
    boolean isDisabled() {
        return getMainCaptureSession().isDisabled();
    }

    @Override
    boolean setDisabled(boolean disabled) {
        return getMainCaptureSession().setDisabled(disabled);
    }

    @Override
    ContentCaptureSession newChild(@NonNull ContentCaptureContext clientContext) {
        final ContentCaptureSession child = new ChildContentCaptureSession(this, clientContext);
        getMainCaptureSession().notifyChildSessionStarted(mId, child.mId, clientContext);
        internalNotifyChildSessionStarted(mId, child.mId, clientContext);
        return child;
    }

@@ -61,51 +83,80 @@ final class ChildContentCaptureSession extends ContentCaptureSession {

    @Override
    public void updateContentCaptureContext(@Nullable ContentCaptureContext context) {
        getMainCaptureSession().notifyContextUpdated(mId, context);
        internalNotifyContextUpdated(mId, context);
    }

    @Override
    void onDestroy() {
        getMainCaptureSession().notifyChildSessionFinished(mParent.mId, mId);
        internalNotifyChildSessionFinished(mParent.mId, mId);
    }

    @Override
    void internalNotifyChildSessionStarted(int parentSessionId, int childSessionId,
            @NonNull ContentCaptureContext clientContext) {
        getMainCaptureSession()
                .internalNotifyChildSessionStarted(parentSessionId, childSessionId, clientContext);
    }

    @Override
    void internalNotifyChildSessionFinished(int parentSessionId, int childSessionId) {
        getMainCaptureSession().internalNotifyChildSessionFinished(parentSessionId, childSessionId);
    }

    @Override
    void internalNotifyContextUpdated(int sessionId, @Nullable ContentCaptureContext context) {
        getMainCaptureSession().internalNotifyContextUpdated(sessionId, context);
    }

    @Override
    void internalNotifyViewAppeared(@NonNull ViewStructureImpl node) {
        getMainCaptureSession().notifyViewAppeared(mId, node);
    void internalNotifyViewAppeared(int sessionId, @NonNull ViewStructureImpl node) {
        getMainCaptureSession().internalNotifyViewAppeared(sessionId, node);
    }

    @Override
    void internalNotifyViewDisappeared(@NonNull AutofillId id) {
        getMainCaptureSession().notifyViewDisappeared(mId, id);
    void internalNotifyViewDisappeared(int sessionId, @NonNull AutofillId id) {
        getMainCaptureSession().internalNotifyViewDisappeared(sessionId, id);
    }

    @Override
    void internalNotifyViewTextChanged(@NonNull AutofillId id, @Nullable CharSequence text) {
        getMainCaptureSession().notifyViewTextChanged(mId, id, text);
    void internalNotifyViewTextChanged(
            int sessionId, @NonNull AutofillId id, @Nullable CharSequence text) {
        getMainCaptureSession().internalNotifyViewTextChanged(sessionId, id, text);
    }

    @Override
    void internalNotifyViewInsetsChanged(@NonNull Insets viewInsets) {
        getMainCaptureSession().notifyViewInsetsChanged(mId, viewInsets);
    void internalNotifyViewInsetsChanged(int sessionId, @NonNull Insets viewInsets) {
        getMainCaptureSession().internalNotifyViewInsetsChanged(mId, viewInsets);
    }

    @Override
    public void internalNotifyViewTreeEvent(boolean started) {
        getMainCaptureSession().notifyViewTreeEvent(mId, started);
    public void internalNotifyViewTreeEvent(int sessionId, boolean started) {
        getMainCaptureSession().internalNotifyViewTreeEvent(sessionId, started);
    }

    @Override
    void internalNotifySessionResumed() {
        getMainCaptureSession().notifySessionResumed();
        getMainCaptureSession().internalNotifySessionResumed();
    }

    @Override
    void internalNotifySessionPaused() {
        getMainCaptureSession().notifySessionPaused();
        getMainCaptureSession().internalNotifySessionPaused();
    }

    @Override
    boolean isContentCaptureEnabled() {
        return getMainCaptureSession().isContentCaptureEnabled();
    }

    @Override
    public void notifyWindowBoundsChanged(int sessionId, @NonNull Rect bounds) {
        getMainCaptureSession().notifyWindowBoundsChanged(sessionId, bounds);
    }

    @Override
    public void notifyContentCaptureEvents(
            @NonNull SparseArray<ArrayList<Object>> contentCaptureEvents) {
        getMainCaptureSession().notifyContentCaptureEvents(contentCaptureEvents);
    }
}
+5 −5
Original line number Diff line number Diff line
@@ -502,7 +502,7 @@ public final class ContentCaptureManager {
    private Handler mHandler;

    @GuardedBy("mLock")
    private MainContentCaptureSession mMainSession;
    private ContentCaptureSession mMainSession;

    @Nullable // set on-demand by addDumpable()
    private Dumper mDumpable;
@@ -587,7 +587,7 @@ public final class ContentCaptureManager {
     */
    @NonNull
    @UiThread
    public MainContentCaptureSession getMainContentCaptureSession() {
    public ContentCaptureSession getMainContentCaptureSession() {
        synchronized (mLock) {
            if (mMainSession == null) {
                mMainSession = new MainContentCaptureSession(
@@ -726,7 +726,7 @@ public final class ContentCaptureManager {
    public boolean isContentCaptureEnabled() {
        if (mOptions.lite) return false;

        final MainContentCaptureSession mainSession;
        final ContentCaptureSession mainSession;
        synchronized (mLock) {
            mainSession = mMainSession;
        }
@@ -777,7 +777,7 @@ public final class ContentCaptureManager {
            Log.d(TAG, "setContentCaptureEnabled(): setting to " + enabled + " for " + mContext);
        }

        MainContentCaptureSession mainSession;
        ContentCaptureSession mainSession;
        synchronized (mLock) {
            if (enabled) {
                mFlags &= ~ContentCaptureContext.FLAG_DISABLED_BY_APP;
@@ -803,7 +803,7 @@ public final class ContentCaptureManager {
        final boolean flagSecureEnabled =
                (params.flags & WindowManager.LayoutParams.FLAG_SECURE) != 0;

        MainContentCaptureSession mainSession;
        ContentCaptureSession mainSession;
        boolean alreadyDisabledByApp;
        synchronized (mLock) {
            alreadyDisabledByApp = (mFlags & ContentCaptureContext.FLAG_DISABLED_BY_APP) != 0;
Loading