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