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

Commit b73c4217 authored by Mihir Patel's avatar Mihir Patel
Browse files

Notifying the on-device intelligence service when view window insets have changed

bug:137800469

Test: manual
Change-Id: Ia69e273a6646fc15e289f75084a81193e71e1eef
parent dfde8e6a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -56741,6 +56741,7 @@ package android.view.contentcapture {
    method public final void notifySessionResumed();
    method public final void notifyViewAppeared(@NonNull android.view.ViewStructure);
    method public final void notifyViewDisappeared(@NonNull android.view.autofill.AutofillId);
    method public final void notifyViewInsetsChanged(@NonNull android.graphics.Insets);
    method public final void notifyViewTextChanged(@NonNull android.view.autofill.AutofillId, @Nullable CharSequence);
    method public final void notifyViewsDisappeared(@NonNull android.view.autofill.AutofillId, @NonNull long[]);
    method public final void setContentCaptureContext(@Nullable android.view.contentcapture.ContentCaptureContext);
+2 −0
Original line number Diff line number Diff line
@@ -13197,6 +13197,7 @@ package android.view.contentcapture {
    method public long getEventTime();
    method @Nullable public android.view.autofill.AutofillId getId();
    method @Nullable public java.util.List<android.view.autofill.AutofillId> getIds();
    method @Nullable public android.graphics.Insets getInsets();
    method @Nullable public CharSequence getText();
    method public int getType();
    method @Nullable public android.view.contentcapture.ViewNode getViewNode();
@@ -13207,6 +13208,7 @@ package android.view.contentcapture {
    field public static final int TYPE_SESSION_RESUMED = 7; // 0x7
    field public static final int TYPE_VIEW_APPEARED = 1; // 0x1
    field public static final int TYPE_VIEW_DISAPPEARED = 2; // 0x2
    field public static final int TYPE_VIEW_INSETS_CHANGED = 9; // 0x9
    field public static final int TYPE_VIEW_TEXT_CHANGED = 3; // 0x3
    field public static final int TYPE_VIEW_TREE_APPEARED = 5; // 0x5
    field public static final int TYPE_VIEW_TREE_APPEARING = 4; // 0x4
+2 −0
Original line number Diff line number Diff line
@@ -5084,6 +5084,7 @@ package android.view.contentcapture {
    method public long getEventTime();
    method @Nullable public android.view.autofill.AutofillId getId();
    method @Nullable public java.util.List<android.view.autofill.AutofillId> getIds();
    method @Nullable public android.graphics.Insets getInsets();
    method @Nullable public CharSequence getText();
    method public int getType();
    method @Nullable public android.view.contentcapture.ViewNode getViewNode();
@@ -5094,6 +5095,7 @@ package android.view.contentcapture {
    field public static final int TYPE_SESSION_RESUMED = 7; // 0x7
    field public static final int TYPE_VIEW_APPEARED = 1; // 0x1
    field public static final int TYPE_VIEW_DISAPPEARED = 2; // 0x2
    field public static final int TYPE_VIEW_INSETS_CHANGED = 9; // 0x9
    field public static final int TYPE_VIEW_TEXT_CHANGED = 3; // 0x3
    field public static final int TYPE_VIEW_TREE_APPEARED = 5; // 0x5
    field public static final int TYPE_VIEW_TREE_APPEARING = 4; // 0x4
+26 −9
Original line number Diff line number Diff line
@@ -29099,8 +29099,33 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            mTreeObserver = new ViewTreeObserver(context);
        }
        @Nullable
        ContentCaptureManager getContentCaptureManager(@NonNull Context context) {
            if (mContentCaptureManager != null) {
                return mContentCaptureManager;
            }
            mContentCaptureManager = context.getSystemService(ContentCaptureManager.class);
            return mContentCaptureManager;
        }
        void delayNotifyContentCaptureInsetsEvent(@NonNull Insets insets) {
            if (mContentCaptureManager == null) {
                return;
            }
            ArrayList<Object> events = ensureEvents(
                        mContentCaptureManager.getMainContentCaptureSession());
            events.add(insets);
        }
        private void delayNotifyContentCaptureEvent(@NonNull ContentCaptureSession session,
                @NonNull View view, boolean appeared) {
            ArrayList<Object> events = ensureEvents(session);
            events.add(appeared ? view : view.getAutofillId());
        }
        @NonNull
        private ArrayList<Object> ensureEvents(@NonNull ContentCaptureSession session) {
            if (mContentCaptureEvents == null) {
                // Most of the time there will be just one session, so intial capacity is 1
                mContentCaptureEvents = new SparseArray<>(1);
@@ -29112,16 +29137,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                events = new ArrayList<>();
                mContentCaptureEvents.put(sessionId, events);
            }
            events.add(appeared ? view : view.getAutofillId());
        }
        @Nullable
        ContentCaptureManager getContentCaptureManager(@NonNull Context context) {
            if (mContentCaptureManager != null) {
                return mContentCaptureManager;
            }
            mContentCaptureManager = context.getSystemService(ContentCaptureManager.class);
            return mContentCaptureManager;
            return events;
        }
    }
+4 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.FrameInfo;
import android.graphics.HardwareRenderer.FrameDrawingCallback;
import android.graphics.Insets;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
import android.graphics.Point;
@@ -2254,6 +2255,7 @@ public final class ViewRootImpl implements ViewParent,
            insets = insets.consumeDisplayCutout();
        }
        host.dispatchApplyWindowInsets(insets);
        mAttachInfo.delayNotifyContentCaptureInsetsEvent(insets.getInsets(Type.all()));
        Trace.traceEnd(Trace.TRACE_TAG_VIEW);
    }

@@ -3118,6 +3120,8 @@ public final class ViewRootImpl implements ViewParent,
                        ViewStructure structure = session.newViewStructure(view);
                        view.onProvideContentCaptureStructure(structure, /* flags= */ 0);
                        session.notifyViewAppeared(structure);
                    } else if (event instanceof Insets) {
                        mainSession.notifyViewInsetsChanged(sessionId, (Insets) event);
                    } else {
                        Log.w(mTag, "invalid content capture event: " + event);
                    }
Loading