Winson Chung | fbbb158 | 2018-11-13 16:09:01 -0800 | [diff] [blame] | 1 | /* |
| 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 Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 17 | package android.service.contentcapture; |
Winson Chung | fbbb158 | 2018-11-13 16:09:01 -0800 | [diff] [blame] | 18 | |
| 19 | import android.annotation.NonNull; |
| 20 | import android.annotation.Nullable; |
| 21 | import android.annotation.SystemApi; |
Felipe Leme | 19652c0 | 2019-02-04 13:01:29 -0800 | [diff] [blame] | 22 | import android.annotation.TestApi; |
Winson Chung | fbbb158 | 2018-11-13 16:09:01 -0800 | [diff] [blame] | 23 | import android.app.assist.AssistContent; |
| 24 | import android.app.assist.AssistStructure; |
| 25 | import android.os.Bundle; |
| 26 | import android.os.Parcel; |
| 27 | import 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 Leme | 19652c0 | 2019-02-04 13:01:29 -0800 | [diff] [blame] | 35 | @TestApi |
Winson Chung | fbbb158 | 2018-11-13 16:09:01 -0800 | [diff] [blame] | 36 | public 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 | */ |
Felipe Leme | ce6877b | 2019-02-28 09:02:26 -0800 | [diff] [blame] | 63 | @NonNull |
Winson Chung | fbbb158 | 2018-11-13 16:09:01 -0800 | [diff] [blame] | 64 | public Bundle getAssistData() { |
| 65 | return mAssistData; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Returns the assist structure for this snapshot. |
| 70 | */ |
Felipe Leme | ce6877b | 2019-02-28 09:02:26 -0800 | [diff] [blame] | 71 | @NonNull |
Winson Chung | fbbb158 | 2018-11-13 16:09:01 -0800 | [diff] [blame] | 72 | public AssistStructure getAssistStructure() { |
| 73 | return mAssistStructure; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Returns the assist context for this snapshot. |
| 78 | */ |
Felipe Leme | ce6877b | 2019-02-28 09:02:26 -0800 | [diff] [blame] | 79 | @Nullable |
Winson Chung | fbbb158 | 2018-11-13 16:09:01 -0800 | [diff] [blame] | 80 | public AssistContent getAssistContent() { |
| 81 | return mAssistContent; |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public int describeContents() { |
| 86 | return 0; |
| 87 | } |
| 88 | |
| 89 | @Override |
| 90 | public void writeToParcel(@NonNull Parcel parcel, int flags) { |
| 91 | parcel.writeBundle(mAssistData); |
| 92 | parcel.writeParcelable(mAssistStructure, flags); |
| 93 | parcel.writeParcelable(mAssistContent, flags); |
| 94 | } |
| 95 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 96 | public static final @android.annotation.NonNull Creator<SnapshotData> CREATOR = |
Winson Chung | fbbb158 | 2018-11-13 16:09:01 -0800 | [diff] [blame] | 97 | new Creator<SnapshotData>() { |
| 98 | |
| 99 | @Override |
Felipe Leme | ce6877b | 2019-02-28 09:02:26 -0800 | [diff] [blame] | 100 | @NonNull |
Winson Chung | fbbb158 | 2018-11-13 16:09:01 -0800 | [diff] [blame] | 101 | public SnapshotData createFromParcel(@NonNull Parcel parcel) { |
| 102 | return new SnapshotData(parcel); |
| 103 | } |
| 104 | |
| 105 | @Override |
Felipe Leme | ce6877b | 2019-02-28 09:02:26 -0800 | [diff] [blame] | 106 | @NonNull |
Winson Chung | fbbb158 | 2018-11-13 16:09:01 -0800 | [diff] [blame] | 107 | public SnapshotData[] newArray(int size) { |
| 108 | return new SnapshotData[size]; |
| 109 | } |
| 110 | }; |
| 111 | } |