summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-01-22 23:05:27 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-01-22 23:05:27 +0000
commit9a8406418d88e4d8a4f1ce3ab35aa81f40694cfd (patch)
tree3db26ff203b910ae99565ad712db075294a16642
parentafad5189552c315cc603f460547eacec57ad333b (diff)
parentb337e1c5ddc7b253f1a497ad7c20dde5efc5c7d7 (diff)
Merge "Added trace points for ContentCapture."
-rw-r--r--core/java/android/app/Activity.java66
-rw-r--r--core/java/android/view/View.java22
2 files changed, 66 insertions, 22 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 836627efb379..1063be4c5c7d 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -74,6 +74,7 @@ import android.os.RemoteException;
import android.os.ServiceManager.ServiceNotFoundException;
import android.os.StrictMode;
import android.os.SystemProperties;
+import android.os.Trace;
import android.os.UserHandle;
import android.text.Selection;
import android.text.SpannableStringBuilder;
@@ -1049,33 +1050,56 @@ public class Activity extends ContextThemeWrapper
@Retention(RetentionPolicy.SOURCE)
@interface ContentCaptureNotificationType{}
-
- private void notifyContentCaptureManagerIfNeeded(@ContentCaptureNotificationType int type) {
- final ContentCaptureManager cm = getContentCaptureManager();
- if (cm == null) return;
-
+ private String getContentCaptureTypeAsString(@ContentCaptureNotificationType int type) {
switch (type) {
case CONTENT_CAPTURE_START:
- //TODO(b/111276913): decide whether the InteractionSessionId should be
- // saved / restored in the activity bundle - probably not
- int flags = 0;
- if ((getWindow().getAttributes().flags
- & WindowManager.LayoutParams.FLAG_SECURE) != 0) {
- flags |= ContentCaptureContext.FLAG_DISABLED_BY_FLAG_SECURE;
- }
- cm.onActivityStarted(mToken, getComponentName(), flags);
- break;
+ return "START";
case CONTENT_CAPTURE_PAUSE:
- cm.flush(ContentCaptureSession.FLUSH_REASON_ACTIVITY_PAUSED);
- break;
+ return "PAUSE";
case CONTENT_CAPTURE_RESUME:
- cm.flush(ContentCaptureSession.FLUSH_REASON_ACTIVITY_RESUMED);
- break;
+ return "RESUME";
case CONTENT_CAPTURE_STOP:
- cm.onActivityStopped();
- break;
+ return "STOP";
default:
- Log.wtf(TAG, "Invalid @ContentCaptureNotificationType: " + type);
+ return "UNKNOW-" + type;
+ }
+ }
+
+ private void notifyContentCaptureManagerIfNeeded(@ContentCaptureNotificationType int type) {
+ if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) {
+ Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER,
+ "notifyContentCapture(" + getContentCaptureTypeAsString(type) + ") for "
+ + mComponent.toShortString());
+ }
+ try {
+ final ContentCaptureManager cm = getContentCaptureManager();
+ if (cm == null) return;
+
+ switch (type) {
+ case CONTENT_CAPTURE_START:
+ //TODO(b/111276913): decide whether the InteractionSessionId should be
+ // saved / restored in the activity bundle - probably not
+ int flags = 0;
+ if ((getWindow().getAttributes().flags
+ & WindowManager.LayoutParams.FLAG_SECURE) != 0) {
+ flags |= ContentCaptureContext.FLAG_DISABLED_BY_FLAG_SECURE;
+ }
+ cm.onActivityStarted(mToken, getComponentName(), flags);
+ break;
+ case CONTENT_CAPTURE_PAUSE:
+ cm.flush(ContentCaptureSession.FLUSH_REASON_ACTIVITY_PAUSED);
+ break;
+ case CONTENT_CAPTURE_RESUME:
+ cm.flush(ContentCaptureSession.FLUSH_REASON_ACTIVITY_RESUMED);
+ break;
+ case CONTENT_CAPTURE_STOP:
+ cm.onActivityStopped();
+ break;
+ default:
+ Log.wtf(TAG, "Invalid @ContentCaptureNotificationType: " + type);
+ }
+ } finally {
+ Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
}
}
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 2131e6d7a528..2014ec2417ac 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -8227,7 +8227,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* </ul>
*/
public void onProvideContentCaptureStructure(@NonNull ViewStructure structure, int flags) {
- onProvideStructure(structure, VIEW_STRUCTURE_FOR_CONTENT_CAPTURE, flags);
+ if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
+ Trace.traceBegin(Trace.TRACE_TAG_VIEW,
+ "onProvideContentCaptureStructure() for " + getClass().getSimpleName());
+ }
+ try {
+ onProvideStructure(structure, VIEW_STRUCTURE_FOR_CONTENT_CAPTURE, flags);
+ } finally {
+ Trace.traceEnd(Trace.TRACE_TAG_VIEW);
+ }
}
/** @hide */
@@ -9017,6 +9025,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* </ol>
*/
private void notifyAppearedOrDisappearedForContentCaptureIfNeeded(boolean appeared) {
+ if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
+ Trace.traceBegin(Trace.TRACE_TAG_VIEW,
+ "notifyContentCapture(" + appeared + ") for " + getClass().getSimpleName());
+ }
+ try {
+ notifyAppearedOrDisappearedForContentCaptureIfNeededNoTrace(appeared);
+ } finally {
+ Trace.traceEnd(Trace.TRACE_TAG_VIEW);
+ }
+ }
+
+ private void notifyAppearedOrDisappearedForContentCaptureIfNeededNoTrace(boolean appeared) {
// First check if context has client, so it saves a service lookup when it doesn't
if (!mContext.isContentCaptureSupported()) return;