blob: 67d3629eeb4980f9763331d704c6ce5a42c5a4c2 [file] [log] [blame]
Felipe Leme1dfa9a02018-10-17 17:24:37 -07001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Felipe Leme749b8892018-12-03 16:30:30 -080016package android.view.contentcapture;
Felipe Leme1dfa9a02018-10-17 17:24:37 -070017
Felipe Lemebe002d82019-01-23 10:22:32 -080018import static android.view.contentcapture.ContentCaptureHelper.getSanitizedString;
19
Felipe Leme1dfa9a02018-10-17 17:24:37 -070020import android.annotation.IntDef;
Felipe Leme88eae3b2018-11-07 15:11:56 -080021import android.annotation.NonNull;
Felipe Leme1dfa9a02018-10-17 17:24:37 -070022import android.annotation.Nullable;
23import android.annotation.SystemApi;
Felipe Leme19652c02019-02-04 13:01:29 -080024import android.annotation.TestApi;
Felipe Leme1dfa9a02018-10-17 17:24:37 -070025import android.os.Parcel;
26import android.os.Parcelable;
Felipe Leme48f363c2019-01-17 10:53:46 -080027import android.util.Log;
Felipe Leme1dfa9a02018-10-17 17:24:37 -070028import android.view.autofill.AutofillId;
29
Felipe Leme88eae3b2018-11-07 15:11:56 -080030import com.android.internal.util.Preconditions;
31
32import java.io.PrintWriter;
Felipe Leme1dfa9a02018-10-17 17:24:37 -070033import java.lang.annotation.Retention;
34import java.lang.annotation.RetentionPolicy;
Felipe Leme48f363c2019-01-17 10:53:46 -080035import java.util.ArrayList;
36import java.util.List;
Felipe Leme1dfa9a02018-10-17 17:24:37 -070037
Felipe Leme1dfa9a02018-10-17 17:24:37 -070038/** @hide */
39@SystemApi
Felipe Leme19652c02019-02-04 13:01:29 -080040@TestApi
Felipe Leme1dfa9a02018-10-17 17:24:37 -070041public final class ContentCaptureEvent implements Parcelable {
42
Felipe Leme48f363c2019-01-17 10:53:46 -080043 private static final String TAG = ContentCaptureEvent.class.getSimpleName();
44
Felipe Leme7a534082018-11-05 15:03:04 -080045 /** @hide */
Felipe Leme87a9dc92018-12-18 14:28:07 -080046 public static final int TYPE_SESSION_FINISHED = -2;
Felipe Leme7a534082018-11-05 15:03:04 -080047 /** @hide */
Felipe Leme87a9dc92018-12-18 14:28:07 -080048 public static final int TYPE_SESSION_STARTED = -1;
Felipe Leme7a534082018-11-05 15:03:04 -080049
Felipe Leme1dfa9a02018-10-17 17:24:37 -070050 /**
Felipe Leme1dfa9a02018-10-17 17:24:37 -070051 * Called when a node has been added to the screen and is visible to the user.
52 *
53 * <p>The metadata of the node is available through {@link #getViewNode()}.
54 */
Felipe Lemeaa5088e2018-12-10 14:53:58 -080055 public static final int TYPE_VIEW_APPEARED = 1;
Felipe Leme1dfa9a02018-10-17 17:24:37 -070056
57 /**
Felipe Leme48f363c2019-01-17 10:53:46 -080058 * Called when one or more nodes have been removed from the screen and is not visible to the
59 * user anymore.
Felipe Leme1dfa9a02018-10-17 17:24:37 -070060 *
Felipe Leme48f363c2019-01-17 10:53:46 -080061 * <p>To get the id(s), first call {@link #getIds()} - if it returns {@code null}, then call
62 * {@link #getId()}.
Felipe Leme1dfa9a02018-10-17 17:24:37 -070063 */
Felipe Lemeaa5088e2018-12-10 14:53:58 -080064 public static final int TYPE_VIEW_DISAPPEARED = 2;
Felipe Leme1dfa9a02018-10-17 17:24:37 -070065
66 /**
67 * Called when the text of a node has been changed.
68 *
69 * <p>The id of the node is available through {@link #getId()}, and the new text is
70 * available through {@link #getText()}.
71 */
Felipe Lemeaa5088e2018-12-10 14:53:58 -080072 public static final int TYPE_VIEW_TEXT_CHANGED = 3;
Felipe Leme1dfa9a02018-10-17 17:24:37 -070073
Felipe Leme01297692019-01-29 18:16:23 -080074 /**
Felipe Leme544b39c2019-02-22 09:26:29 -080075 * Called before events (such as {@link #TYPE_VIEW_APPEARED} and/or
76 * {@link #TYPE_VIEW_DISAPPEARED}) representing a view hierarchy are sent.
Felipe Leme01297692019-01-29 18:16:23 -080077 *
78 * <p><b>NOTE</b>: there is no guarantee this event will be sent. For example, it's not sent
79 * if the initial view hierarchy doesn't initially have any view that's important for content
80 * capture.
81 */
Felipe Lemeb0da18f2019-02-22 15:10:02 -080082 public static final int TYPE_VIEW_TREE_APPEARING = 4;
Felipe Leme01297692019-01-29 18:16:23 -080083
84 /**
Felipe Leme544b39c2019-02-22 09:26:29 -080085 * Called after events (such as {@link #TYPE_VIEW_APPEARED} and/or
86 * {@link #TYPE_VIEW_DISAPPEARED}) representing a view hierarchy were sent.
Felipe Leme01297692019-01-29 18:16:23 -080087 *
88 * <p><b>NOTE</b>: there is no guarantee this event will be sent. For example, it's not sent
89 * if the initial view hierarchy doesn't initially have any view that's important for content
90 * capture.
91 */
Felipe Lemeb0da18f2019-02-22 15:10:02 -080092 public static final int TYPE_VIEW_TREE_APPEARED = 5;
Felipe Leme1dfa9a02018-10-17 17:24:37 -070093
Felipe Leme4eecbe62019-02-11 17:50:17 -080094 /**
95 * Called after a call to
96 * {@link ContentCaptureSession#setContentCaptureContext(ContentCaptureContext)}.
97 *
98 * <p>The passed context is available through {@link #getContentCaptureContext()}.
99 */
100 public static final int TYPE_CONTEXT_UPDATED = 6;
101
Felipe Lemeb0da18f2019-02-22 15:10:02 -0800102 /**
103 * Called after the session is ready, typically after the activity resumed and the
104 * initial views appeared
105 */
106 public static final int TYPE_SESSION_RESUMED = 7;
107
108 /**
109 * Called after the session is paused, typically after the activity paused and the
110 * views disappeared.
111 */
112 public static final int TYPE_SESSION_PAUSED = 8;
113
114
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700115 /** @hide */
116 @IntDef(prefix = { "TYPE_" }, value = {
Felipe Leme88eae3b2018-11-07 15:11:56 -0800117 TYPE_VIEW_APPEARED,
118 TYPE_VIEW_DISAPPEARED,
Felipe Leme01297692019-01-29 18:16:23 -0800119 TYPE_VIEW_TEXT_CHANGED,
Felipe Lemeb0da18f2019-02-22 15:10:02 -0800120 TYPE_VIEW_TREE_APPEARING,
121 TYPE_VIEW_TREE_APPEARED,
122 TYPE_CONTEXT_UPDATED,
123 TYPE_SESSION_PAUSED,
124 TYPE_SESSION_RESUMED
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700125 })
126 @Retention(RetentionPolicy.SOURCE)
Felipe Leme7a534082018-11-05 15:03:04 -0800127 public @interface EventType{}
128
Felipe Lemefc24bea2018-12-18 13:19:01 -0800129 private final @NonNull String mSessionId;
Felipe Leme7a534082018-11-05 15:03:04 -0800130 private final int mType;
131 private final long mEventTime;
Felipe Leme88eae3b2018-11-07 15:11:56 -0800132 private @Nullable AutofillId mId;
Felipe Leme48f363c2019-01-17 10:53:46 -0800133 private @Nullable ArrayList<AutofillId> mIds;
Felipe Leme88eae3b2018-11-07 15:11:56 -0800134 private @Nullable ViewNode mNode;
135 private @Nullable CharSequence mText;
Felipe Leme87a9dc92018-12-18 14:28:07 -0800136 private @Nullable String mParentSessionId;
137 private @Nullable ContentCaptureContext mClientContext;
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700138
139 /** @hide */
Felipe Leme21e8dcb2019-01-18 09:09:45 -0800140 public ContentCaptureEvent(@NonNull String sessionId, int type, long eventTime) {
Felipe Lemefc24bea2018-12-18 13:19:01 -0800141 mSessionId = sessionId;
Felipe Leme7a534082018-11-05 15:03:04 -0800142 mType = type;
143 mEventTime = eventTime;
Felipe Leme88eae3b2018-11-07 15:11:56 -0800144 }
145
146 /** @hide */
Felipe Lemefc24bea2018-12-18 13:19:01 -0800147 public ContentCaptureEvent(@NonNull String sessionId, int type) {
Felipe Leme21e8dcb2019-01-18 09:09:45 -0800148 this(sessionId, type, System.currentTimeMillis());
Felipe Leme88eae3b2018-11-07 15:11:56 -0800149 }
150
151 /** @hide */
152 public ContentCaptureEvent setAutofillId(@NonNull AutofillId id) {
153 mId = Preconditions.checkNotNull(id);
154 return this;
155 }
156
Felipe Leme01297692019-01-29 18:16:23 -0800157 /** @hide */
158 public ContentCaptureEvent setAutofillIds(@NonNull ArrayList<AutofillId> ids) {
Felipe Leme48f363c2019-01-17 10:53:46 -0800159 mIds = Preconditions.checkNotNull(ids);
Felipe Leme01297692019-01-29 18:16:23 -0800160 return this;
Felipe Leme48f363c2019-01-17 10:53:46 -0800161 }
162
163 /**
164 * Adds an autofill id to the this event, merging the single id into a list if necessary.
Felipe Leme2ca5dfe2019-02-05 12:22:50 -0800165 *
166 * @hide
167 */
Felipe Leme48f363c2019-01-17 10:53:46 -0800168 public ContentCaptureEvent addAutofillId(@NonNull AutofillId id) {
Felipe Leme2ca5dfe2019-02-05 12:22:50 -0800169 Preconditions.checkNotNull(id);
Felipe Leme48f363c2019-01-17 10:53:46 -0800170 if (mIds == null) {
171 mIds = new ArrayList<>();
172 if (mId == null) {
173 Log.w(TAG, "addAutofillId(" + id + ") called without an initial id");
174 } else {
175 mIds.add(mId);
176 mId = null;
177 }
178 }
179 mIds.add(id);
180 return this;
181 }
182
Felipe Leme87a9dc92018-12-18 14:28:07 -0800183 /**
184 * Used by {@link #TYPE_SESSION_STARTED} and {@link #TYPE_SESSION_FINISHED}.
185 *
186 * @hide
187 */
188 public ContentCaptureEvent setParentSessionId(@NonNull String parentSessionId) {
189 mParentSessionId = parentSessionId;
190 return this;
191 }
192
193 /**
194 * Used by {@link #TYPE_SESSION_STARTED} and {@link #TYPE_SESSION_FINISHED}.
195 *
196 * @hide
197 */
198 public ContentCaptureEvent setClientContext(@NonNull ContentCaptureContext clientContext) {
199 mClientContext = clientContext;
200 return this;
201 }
202
Felipe Leme88eae3b2018-11-07 15:11:56 -0800203 /** @hide */
Felipe Lemefc24bea2018-12-18 13:19:01 -0800204 @NonNull
205 public String getSessionId() {
206 return mSessionId;
207 }
208
Felipe Leme87a9dc92018-12-18 14:28:07 -0800209 /**
210 * Used by {@link #TYPE_SESSION_STARTED} and {@link #TYPE_SESSION_FINISHED}.
211 *
212 * @hide
213 */
214 @Nullable
215 public String getParentSessionId() {
216 return mParentSessionId;
217 }
218
219 /**
Felipe Leme4eecbe62019-02-11 17:50:17 -0800220 * Gets the {@link ContentCaptureContext} set calls to
221 * {@link ContentCaptureSession#setContentCaptureContext(ContentCaptureContext)}.
Felipe Leme87a9dc92018-12-18 14:28:07 -0800222 *
Felipe Leme4eecbe62019-02-11 17:50:17 -0800223 * <p>Only set on {@link #TYPE_CONTEXT_UPDATED} events.
Felipe Leme87a9dc92018-12-18 14:28:07 -0800224 */
225 @Nullable
Felipe Leme4eecbe62019-02-11 17:50:17 -0800226 public ContentCaptureContext getContentCaptureContext() {
Felipe Leme87a9dc92018-12-18 14:28:07 -0800227 return mClientContext;
228 }
229
Felipe Lemefc24bea2018-12-18 13:19:01 -0800230 /** @hide */
231 @NonNull
Felipe Leme88eae3b2018-11-07 15:11:56 -0800232 public ContentCaptureEvent setViewNode(@NonNull ViewNode node) {
233 mNode = Preconditions.checkNotNull(node);
234 return this;
235 }
236
237 /** @hide */
Felipe Lemefc24bea2018-12-18 13:19:01 -0800238 @NonNull
Felipe Leme88eae3b2018-11-07 15:11:56 -0800239 public ContentCaptureEvent setText(@Nullable CharSequence text) {
240 mText = text;
241 return this;
242 }
243
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700244 /**
245 * Gets the type of the event.
246 *
Felipe Lemeaa5088e2018-12-10 14:53:58 -0800247 * @return one of {@link #TYPE_VIEW_APPEARED}, {@link #TYPE_VIEW_DISAPPEARED},
Felipe Lemeb0da18f2019-02-22 15:10:02 -0800248 * {@link #TYPE_VIEW_TEXT_CHANGED}, {@link #TYPE_VIEW_TREE_APPEARING},
249 * {@link #TYPE_VIEW_TREE_APPEARED}, {@link #TYPE_CONTEXT_UPDATED},
250 * {@link #TYPE_SESSION_RESUMED}, or {@link #TYPE_SESSION_PAUSED}.
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700251 */
252 public @EventType int getType() {
Felipe Leme7a534082018-11-05 15:03:04 -0800253 return mType;
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700254 }
255
256 /**
Felipe Lemeaa5088e2018-12-10 14:53:58 -0800257 * Gets when the event was generated, in millis since epoch.
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700258 */
259 public long getEventTime() {
Felipe Leme7a534082018-11-05 15:03:04 -0800260 return mEventTime;
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700261 }
262
263 /**
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700264 * Gets the whole metadata of the node associated with the event.
265 *
Felipe Leme88eae3b2018-11-07 15:11:56 -0800266 * <p>Only set on {@link #TYPE_VIEW_APPEARED} events.
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700267 */
268 @Nullable
269 public ViewNode getViewNode() {
Felipe Leme88eae3b2018-11-07 15:11:56 -0800270 return mNode;
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700271 }
272
273 /**
274 * Gets the {@link AutofillId} of the node associated with the event.
275 *
Felipe Leme48f363c2019-01-17 10:53:46 -0800276 * <p>Only set on {@link #TYPE_VIEW_DISAPPEARED} (when the event contains just one node - if
277 * it contains more than one, this method returns {@code null} and the actual ids should be
278 * retrived by {@link #getIds()}) and {@link #TYPE_VIEW_TEXT_CHANGED} events.
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700279 */
280 @Nullable
281 public AutofillId getId() {
Felipe Leme88eae3b2018-11-07 15:11:56 -0800282 return mId;
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700283 }
284
285 /**
Felipe Leme48f363c2019-01-17 10:53:46 -0800286 * Gets the {@link AutofillId AutofillIds} of the nodes associated with the event.
287 *
288 * <p>Only set on {@link #TYPE_VIEW_DISAPPEARED}, when the event contains more than one node
289 * (if it contains just one node, it's returned by {@link #getId()} instead.
290 */
291 @Nullable
292 public List<AutofillId> getIds() {
293 return mIds;
294 }
295
296 /**
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700297 * Gets the current text of the node associated with the event.
298 *
299 * <p>Only set on {@link #TYPE_VIEW_TEXT_CHANGED} events.
300 */
301 @Nullable
302 public CharSequence getText() {
Felipe Leme88eae3b2018-11-07 15:11:56 -0800303 return mText;
304 }
305
306 /** @hide */
307 public void dump(@NonNull PrintWriter pw) {
308 pw.print("type="); pw.print(getTypeAsString(mType));
309 pw.print(", time="); pw.print(mEventTime);
Felipe Leme88eae3b2018-11-07 15:11:56 -0800310 if (mId != null) {
311 pw.print(", id="); pw.print(mId);
312 }
Felipe Leme48f363c2019-01-17 10:53:46 -0800313 if (mIds != null) {
314 pw.print(", ids="); pw.print(mIds);
315 }
Felipe Leme88eae3b2018-11-07 15:11:56 -0800316 if (mNode != null) {
Felipe Leme87a9dc92018-12-18 14:28:07 -0800317 pw.print(", mNode.id="); pw.print(mNode.getAutofillId());
318 }
319 if (mSessionId != null) {
320 pw.print(", sessionId="); pw.print(mSessionId);
321 }
322 if (mParentSessionId != null) {
323 pw.print(", parentSessionId="); pw.print(mParentSessionId);
324 }
325 if (mText != null) {
Felipe Lemebe002d82019-01-23 10:22:32 -0800326 pw.print(", text="); pw.println(getSanitizedString(mText));
Felipe Leme88eae3b2018-11-07 15:11:56 -0800327 }
Felipe Leme4eecbe62019-02-11 17:50:17 -0800328 if (mClientContext != null) {
329 pw.print(", context="); mClientContext.dump(pw); pw.println();
330
331 }
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700332 }
333
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700334 @Override
Felipe Leme7a534082018-11-05 15:03:04 -0800335 public String toString() {
336 final StringBuilder string = new StringBuilder("ContentCaptureEvent[type=")
Felipe Leme88eae3b2018-11-07 15:11:56 -0800337 .append(getTypeAsString(mType));
Felipe Lemee127c9a2019-01-04 14:56:38 -0800338 string.append(", session=").append(mSessionId);
339 if (mType == TYPE_SESSION_STARTED && mParentSessionId != null) {
340 string.append(", parent=").append(mParentSessionId);
341 }
Felipe Leme88eae3b2018-11-07 15:11:56 -0800342 if (mId != null) {
343 string.append(", id=").append(mId);
344 }
Felipe Leme48f363c2019-01-17 10:53:46 -0800345 if (mIds != null) {
346 string.append(", ids=").append(mIds);
347 }
Felipe Leme88eae3b2018-11-07 15:11:56 -0800348 if (mNode != null) {
349 final String className = mNode.getClassName();
350 if (mNode != null) {
351 string.append(", class=").append(className);
352 }
353 string.append(", id=").append(mNode.getAutofillId());
354 }
Felipe Lemebe002d82019-01-23 10:22:32 -0800355 if (mText != null) {
356 string.append(", text=").append(getSanitizedString(mText));
357 }
Felipe Leme4eecbe62019-02-11 17:50:17 -0800358 if (mClientContext != null) {
359 string.append(", context=").append(mClientContext);
360 }
Felipe Leme7a534082018-11-05 15:03:04 -0800361 return string.append(']').toString();
362 }
363
364 @Override
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700365 public int describeContents() {
366 return 0;
367 }
368
369 @Override
370 public void writeToParcel(Parcel parcel, int flags) {
Felipe Lemefc24bea2018-12-18 13:19:01 -0800371 parcel.writeString(mSessionId);
Felipe Leme7a534082018-11-05 15:03:04 -0800372 parcel.writeInt(mType);
373 parcel.writeLong(mEventTime);
Felipe Leme88eae3b2018-11-07 15:11:56 -0800374 parcel.writeParcelable(mId, flags);
Felipe Leme48f363c2019-01-17 10:53:46 -0800375 parcel.writeTypedList(mIds);
Felipe Leme88eae3b2018-11-07 15:11:56 -0800376 ViewNode.writeToParcel(parcel, mNode, flags);
377 parcel.writeCharSequence(mText);
Felipe Leme87a9dc92018-12-18 14:28:07 -0800378 if (mType == TYPE_SESSION_STARTED || mType == TYPE_SESSION_FINISHED) {
379 parcel.writeString(mParentSessionId);
380 }
Felipe Leme4eecbe62019-02-11 17:50:17 -0800381 if (mType == TYPE_SESSION_STARTED || mType == TYPE_CONTEXT_UPDATED) {
Felipe Leme87a9dc92018-12-18 14:28:07 -0800382 parcel.writeParcelable(mClientContext, flags);
383 }
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700384 }
385
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -0700386 public static final @android.annotation.NonNull Parcelable.Creator<ContentCaptureEvent> CREATOR =
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700387 new Parcelable.Creator<ContentCaptureEvent>() {
388
389 @Override
Felipe Lemece6877b2019-02-28 09:02:26 -0800390 @NonNull
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700391 public ContentCaptureEvent createFromParcel(Parcel parcel) {
Felipe Lemefc24bea2018-12-18 13:19:01 -0800392 final String sessionId = parcel.readString();
Felipe Leme7a534082018-11-05 15:03:04 -0800393 final int type = parcel.readInt();
394 final long eventTime = parcel.readLong();
Felipe Leme21e8dcb2019-01-18 09:09:45 -0800395 final ContentCaptureEvent event = new ContentCaptureEvent(sessionId, type, eventTime);
Felipe Leme88eae3b2018-11-07 15:11:56 -0800396 final AutofillId id = parcel.readParcelable(null);
397 if (id != null) {
398 event.setAutofillId(id);
399 }
Felipe Leme48f363c2019-01-17 10:53:46 -0800400 final ArrayList<AutofillId> ids = parcel.createTypedArrayList(AutofillId.CREATOR);
401 if (ids != null) {
402 event.setAutofillIds(ids);
403 }
Felipe Leme88eae3b2018-11-07 15:11:56 -0800404 final ViewNode node = ViewNode.readFromParcel(parcel);
405 if (node != null) {
406 event.setViewNode(node);
407 }
408 event.setText(parcel.readCharSequence());
Felipe Leme87a9dc92018-12-18 14:28:07 -0800409 if (type == TYPE_SESSION_STARTED || type == TYPE_SESSION_FINISHED) {
410 event.setParentSessionId(parcel.readString());
411 }
Felipe Leme4eecbe62019-02-11 17:50:17 -0800412 if (type == TYPE_SESSION_STARTED || type == TYPE_CONTEXT_UPDATED) {
Felipe Leme87a9dc92018-12-18 14:28:07 -0800413 event.setClientContext(parcel.readParcelable(null));
414 }
Felipe Leme88eae3b2018-11-07 15:11:56 -0800415 return event;
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700416 }
417
418 @Override
Felipe Lemece6877b2019-02-28 09:02:26 -0800419 @NonNull
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700420 public ContentCaptureEvent[] newArray(int size) {
421 return new ContentCaptureEvent[size];
422 }
423 };
Felipe Leme7a534082018-11-05 15:03:04 -0800424
Felipe Leme7a534082018-11-05 15:03:04 -0800425 /** @hide */
426 public static String getTypeAsString(@EventType int type) {
427 switch (type) {
Felipe Leme87a9dc92018-12-18 14:28:07 -0800428 case TYPE_SESSION_STARTED:
429 return "SESSION_STARTED";
430 case TYPE_SESSION_FINISHED:
431 return "SESSION_FINISHED";
Felipe Lemeb0da18f2019-02-22 15:10:02 -0800432 case TYPE_SESSION_RESUMED:
433 return "SESSION_RESUMED";
434 case TYPE_SESSION_PAUSED:
435 return "SESSION_PAUSED";
Felipe Leme88eae3b2018-11-07 15:11:56 -0800436 case TYPE_VIEW_APPEARED:
437 return "VIEW_APPEARED";
438 case TYPE_VIEW_DISAPPEARED:
439 return "VIEW_DISAPPEARED";
Felipe Leme7a534082018-11-05 15:03:04 -0800440 case TYPE_VIEW_TEXT_CHANGED:
441 return "VIEW_TEXT_CHANGED";
Felipe Lemeb0da18f2019-02-22 15:10:02 -0800442 case TYPE_VIEW_TREE_APPEARING:
Felipe Leme544b39c2019-02-22 09:26:29 -0800443 return "VIEW_TREE_APPEARING";
Felipe Lemeb0da18f2019-02-22 15:10:02 -0800444 case TYPE_VIEW_TREE_APPEARED:
Felipe Leme544b39c2019-02-22 09:26:29 -0800445 return "VIEW_TREE_APPEARED";
Felipe Leme4eecbe62019-02-11 17:50:17 -0800446 case TYPE_CONTEXT_UPDATED:
447 return "CONTEXT_UPDATED";
Felipe Leme7a534082018-11-05 15:03:04 -0800448 default:
449 return "UKNOWN_TYPE: " + type;
450 }
451 }
Felipe Leme1dfa9a02018-10-17 17:24:37 -0700452}