summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/View.java25
1 files changed, 14 insertions, 11 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 8c8b9d34f876..7ee3973a40aa 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -5125,6 +5125,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
@Nullable
private ContentCaptureSession mContentCaptureSession;
+ /**
+ * Whether {@link ContentCaptureSession} is cached, resets on {@link #invalidate()}.
+ */
+ private boolean mContentCaptureSessionCached;
+
@LayoutRes
private int mSourceLayoutId = ID_NULL;
@@ -5138,11 +5143,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
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.
*
* @param context The Context the view is running in, through which it can
@@ -9560,18 +9560,21 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*/
@Nullable
public final ContentCaptureSession getContentCaptureSession() {
- if (mCachedContentCaptureSession != null) {
- return mCachedContentCaptureSession;
+ if (mContentCaptureSessionCached) {
+ return mContentCaptureSession;
}
- mCachedContentCaptureSession = getAndCacheContentCaptureSession();
- return mCachedContentCaptureSession;
+ mContentCaptureSession = getAndCacheContentCaptureSession();
+ mContentCaptureSessionCached = true;
+ return mContentCaptureSession;
}
@Nullable
private ContentCaptureSession getAndCacheContentCaptureSession() {
// 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
ContentCaptureSession session = null;
@@ -18094,7 +18097,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
// Reset content capture caches
mPrivateFlags4 &= ~PFLAG4_CONTENT_CAPTURE_IMPORTANCE_MASK;
- mCachedContentCaptureSession = null;
+ mContentCaptureSessionCached = false;
if ((mPrivateFlags & (PFLAG_DRAWN | PFLAG_HAS_BOUNDS)) == (PFLAG_DRAWN | PFLAG_HAS_BOUNDS)
|| (invalidateCache && (mPrivateFlags & PFLAG_DRAWING_CACHE_VALID) == PFLAG_DRAWING_CACHE_VALID)