Merge "Refine performance for calling into ContentCapture" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-24 03:31:20 +00:00
committed by Android (Google) Code Review

View File

@@ -9581,18 +9581,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
// First check if context has client, so it saves a service lookup when it doesn't // First check if context has client, so it saves a service lookup when it doesn't
if (mContext.getContentCaptureOptions() == null) return; if (mContext.getContentCaptureOptions() == null) return;
// Then check if it's enabled in the context...
final ContentCaptureManager ccm = ai != null ? ai.getContentCaptureManager(mContext)
: mContext.getSystemService(ContentCaptureManager.class);
if (ccm == null || !ccm.isContentCaptureEnabled()) return;
// ... and finally at the view level
// NOTE: isImportantForContentCapture() is more expensive than cm.isContentCaptureEnabled()
if (!isImportantForContentCapture()) return;
ContentCaptureSession session = getContentCaptureSession();
if (session == null) return;
if (appeared) { if (appeared) {
if (!isLaidOut() || getVisibility() != VISIBLE if (!isLaidOut() || getVisibility() != VISIBLE
|| (mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0) { || (mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0) {
@@ -9601,12 +9589,36 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
+ isLaidOut() + ", visibleToUser=" + isVisibleToUser() + isLaidOut() + ", visibleToUser=" + isVisibleToUser()
+ ", visible=" + (getVisibility() == VISIBLE) + ", visible=" + (getVisibility() == VISIBLE)
+ ": alreadyNotifiedAppeared=" + ((mPrivateFlags4 + ": alreadyNotifiedAppeared=" + ((mPrivateFlags4
& PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0) & PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0)
+ ", alreadyNotifiedDisappeared=" + ((mPrivateFlags4 + ", alreadyNotifiedDisappeared=" + ((mPrivateFlags4
& PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0)); & PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0));
} }
return; return;
} }
} else {
if ((mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) == 0
|| (mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0) {
if (DEBUG_CONTENT_CAPTURE) {
Log.v(CONTENT_CAPTURE_LOG_TAG, "Ignoring 'disappeared' on " + this + ": laid="
+ isLaidOut() + ", visibleToUser=" + isVisibleToUser()
+ ", visible=" + (getVisibility() == VISIBLE)
+ ": alreadyNotifiedAppeared=" + ((mPrivateFlags4
& PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0)
+ ", alreadyNotifiedDisappeared=" + ((mPrivateFlags4
& PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0));
}
return;
}
}
ContentCaptureSession session = getContentCaptureSession();
if (session == null) return;
// ... and finally at the view level
// NOTE: isImportantForContentCapture() is more expensive than cm.isContentCaptureEnabled()
if (!isImportantForContentCapture()) return;
if (appeared) {
setNotifiedContentCaptureAppeared(); setNotifiedContentCaptureAppeared();
if (ai != null) { if (ai != null) {
@@ -9617,19 +9629,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
} }
} }
} else { } else {
if ((mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) == 0
|| (mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0) {
if (DEBUG_CONTENT_CAPTURE) {
Log.v(CONTENT_CAPTURE_LOG_TAG, "Ignoring 'disappeared' on " + this + ": laid="
+ isLaidOut() + ", visibleToUser=" + isVisibleToUser()
+ ", visible=" + (getVisibility() == VISIBLE)
+ ": alreadyNotifiedAppeared=" + ((mPrivateFlags4
& PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0)
+ ", alreadyNotifiedDisappeared=" + ((mPrivateFlags4
& PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0));
}
return;
}
mPrivateFlags4 |= PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED; mPrivateFlags4 |= PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED;
mPrivateFlags4 &= ~PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED; mPrivateFlags4 &= ~PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED;