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