2 * Copyright (C) 2017 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.service.autofill;
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Bundle;
22 import android.os.CancellationSignal;
23 import android.os.Parcel;
24 import android.os.Parcelable;
25 import com.android.internal.util.Preconditions;
27 import java.util.ArrayList;
28 import java.util.List;
31 * This class represents a request to an {@link AutofillService
32 * autofill provider} to save applicable data entered by the user.
34 * @see AutofillService#onSaveRequest(SaveRequest, SaveCallback)
36 public final class SaveRequest implements Parcelable {
37 private final @NonNull ArrayList<FillContext> mFillContexts;
38 private final @Nullable Bundle mClientState;
41 public SaveRequest(@NonNull ArrayList<FillContext> fillContexts,
42 @Nullable Bundle clientState) {
43 mFillContexts = Preconditions.checkNotNull(fillContexts, "fillContexts");
44 mClientState = clientState;
47 private SaveRequest(@NonNull Parcel parcel) {
48 this(parcel.readTypedArrayList(null), parcel.readBundle());
52 * @return The contexts associated with each previous fill request.
54 public @NonNull List<FillContext> getFillContexts() {
59 * Gets the extra client state returned from the last {@link
60 * AutofillService#onFillRequest(FillRequest, CancellationSignal, FillCallback)}
63 * @return The client state.
65 public @Nullable Bundle getClientState() {
70 public int describeContents() {
75 public void writeToParcel(Parcel parcel, int flags) {
76 parcel.writeTypedArrayList(mFillContexts, flags);
77 parcel.writeBundle(mClientState);
80 public static final Creator<SaveRequest> CREATOR =
81 new Creator<SaveRequest>() {
83 public SaveRequest createFromParcel(Parcel parcel) {
84 return new SaveRequest(parcel);
88 public SaveRequest[] newArray(int size) {
89 return new SaveRequest[size];