blob: c3af1f0cc60868a553c7de3069fda087d468368c [file] [log] [blame]
Winson Chungfbbb1582018-11-13 16:09:01 -08001/*
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 */
16
Felipe Leme749b8892018-12-03 16:30:30 -080017package android.service.contentcapture;
Winson Chungfbbb1582018-11-13 16:09:01 -080018
19import android.annotation.NonNull;
20import android.annotation.Nullable;
21import android.annotation.SystemApi;
Felipe Leme19652c02019-02-04 13:01:29 -080022import android.annotation.TestApi;
Winson Chungfbbb1582018-11-13 16:09:01 -080023import android.app.assist.AssistContent;
24import android.app.assist.AssistStructure;
25import android.os.Bundle;
26import android.os.Parcel;
27import android.os.Parcelable;
28
29/**
30 * A container class for data taken from a snapshot of an activity.
31 *
32 * @hide
33 */
34@SystemApi
Felipe Leme19652c02019-02-04 13:01:29 -080035@TestApi
Winson Chungfbbb1582018-11-13 16:09:01 -080036public final class SnapshotData implements Parcelable {
37
38 private final @NonNull Bundle mAssistData;
39 private final @NonNull AssistStructure mAssistStructure;
40 private final @Nullable AssistContent mAssistContent;
41
42 /**
43 * Creates a new instance.
44 *
45 * @hide
46 */
47 public SnapshotData(@NonNull Bundle assistData, @NonNull AssistStructure assistStructure,
48 @Nullable AssistContent assistContent) {
49 mAssistData = assistData;
50 mAssistStructure = assistStructure;
51 mAssistContent = assistContent;
52 }
53
54 SnapshotData(@NonNull Parcel parcel) {
55 mAssistData = parcel.readBundle();
56 mAssistStructure = parcel.readParcelable(null);
57 mAssistContent = parcel.readParcelable(null);
58 }
59
60 /**
61 * Returns the assist data for this snapshot.
62 */
63 public Bundle getAssistData() {
64 return mAssistData;
65 }
66
67 /**
68 * Returns the assist structure for this snapshot.
69 */
70 public AssistStructure getAssistStructure() {
71 return mAssistStructure;
72 }
73
74 /**
75 * Returns the assist context for this snapshot.
76 */
77 public AssistContent getAssistContent() {
78 return mAssistContent;
79 }
80
81 @Override
82 public int describeContents() {
83 return 0;
84 }
85
86 @Override
87 public void writeToParcel(@NonNull Parcel parcel, int flags) {
88 parcel.writeBundle(mAssistData);
89 parcel.writeParcelable(mAssistStructure, flags);
90 parcel.writeParcelable(mAssistContent, flags);
91 }
92
93 public static final Creator<SnapshotData> CREATOR =
94 new Creator<SnapshotData>() {
95
96 @Override
97 public SnapshotData createFromParcel(@NonNull Parcel parcel) {
98 return new SnapshotData(parcel);
99 }
100
101 @Override
102 public SnapshotData[] newArray(int size) {
103 return new SnapshotData[size];
104 }
105 };
106}