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

Commit 37148c93 authored by Adam He's avatar Adam He
Browse files

Merge mContentCaptureSession and mCachedContentCaptureSession.

Fixes: 124308646
Test: atest android.contentcaptureservice.cts.LoginActivityTest#testContentCaptureSessionCache
Test: atest CtsContentCaptureServiceTestCases
Change-Id: I3c32e14c4022ec68195470945775ab06ba72ec96
parent b63ff32f
Loading
Loading
Loading
Loading
+14 −11
Original line number Original line Diff line number Diff line
@@ -5125,6 +5125,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    @Nullable
    @Nullable
    private ContentCaptureSession mContentCaptureSession;
    private ContentCaptureSession mContentCaptureSession;
    /**
     * Whether {@link ContentCaptureSession} is cached, resets on {@link #invalidate()}.
     */
    private boolean mContentCaptureSessionCached;
    @LayoutRes
    @LayoutRes
    private int mSourceLayoutId = ID_NULL;
    private int mSourceLayoutId = ID_NULL;
@@ -5137,11 +5142,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    @StyleRes
    @StyleRes
    private int mExplicitStyle;
    private int mExplicitStyle;
    /**
     * Cached reference to the {@link ContentCaptureSession}, is reset on {@link #invalidate()}.
     */
    private ContentCaptureSession mCachedContentCaptureSession;
    /**
    /**
     * Simple constructor to use when creating a view from code.
     * Simple constructor to use when creating a view from code.
     *
     *
@@ -9560,18 +9560,21 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
     */
    @Nullable
    @Nullable
    public final ContentCaptureSession getContentCaptureSession() {
    public final ContentCaptureSession getContentCaptureSession() {
        if (mCachedContentCaptureSession != null) {
        if (mContentCaptureSessionCached) {
            return mCachedContentCaptureSession;
            return mContentCaptureSession;
        }
        }
        mCachedContentCaptureSession = getAndCacheContentCaptureSession();
        mContentCaptureSession = getAndCacheContentCaptureSession();
        return mCachedContentCaptureSession;
        mContentCaptureSessionCached = true;
        return mContentCaptureSession;
    }
    }
    @Nullable
    @Nullable
    private ContentCaptureSession getAndCacheContentCaptureSession() {
    private ContentCaptureSession getAndCacheContentCaptureSession() {
        // First try the session explicitly set by setContentCaptureSession()
        // First try the session explicitly set by setContentCaptureSession()
        if (mContentCaptureSession != null) return mContentCaptureSession;
        if (mContentCaptureSession != null) {
            return mContentCaptureSession;
        }
        // Then the session explicitly set in an ancestor
        // Then the session explicitly set in an ancestor
        ContentCaptureSession session = null;
        ContentCaptureSession session = null;
@@ -18084,7 +18087,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        // Reset content capture caches
        // Reset content capture caches
        mPrivateFlags4 &= ~PFLAG4_CONTENT_CAPTURE_IMPORTANCE_MASK;
        mPrivateFlags4 &= ~PFLAG4_CONTENT_CAPTURE_IMPORTANCE_MASK;
        mCachedContentCaptureSession = null;
        mContentCaptureSessionCached = false;
        if ((mPrivateFlags & (PFLAG_DRAWN | PFLAG_HAS_BOUNDS)) == (PFLAG_DRAWN | PFLAG_HAS_BOUNDS)
        if ((mPrivateFlags & (PFLAG_DRAWN | PFLAG_HAS_BOUNDS)) == (PFLAG_DRAWN | PFLAG_HAS_BOUNDS)
                || (invalidateCache && (mPrivateFlags & PFLAG_DRAWING_CACHE_VALID) == PFLAG_DRAWING_CACHE_VALID)
                || (invalidateCache && (mPrivateFlags & PFLAG_DRAWING_CACHE_VALID) == PFLAG_DRAWING_CACHE_VALID)