blob: 7064b6fe80795f01b1eec0d56571330a579fb469 [file] [log] [blame]
Felipe Leme284ad1c2018-11-15 18:16:12 -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 */
Felipe Leme749b8892018-12-03 16:30:30 -080016package android.service.autofill.augmented;
Felipe Leme284ad1c2018-11-15 18:16:12 -080017
18import android.annotation.NonNull;
19import android.annotation.Nullable;
20import android.annotation.SystemApi;
21import android.os.Parcel;
22import android.os.Parcelable;
23import android.view.autofill.AutofillId;
24
25import java.util.List;
26
27/**
28 * Response to a {@link FillRequest}.
29 *
30 * @hide
31 */
32@SystemApi
33public final class FillResponse implements Parcelable {
34
35 private final FillWindow mFillWindow;
36
37 private FillResponse(@NonNull Builder builder) {
38 mFillWindow = builder.mFillWindow;
39 }
40
41 /** @hide */
42 @Nullable
43 FillWindow getFillWindow() {
44 return mFillWindow;
45 }
46
47 /**
48 * Builder for {@link FillResponse} objects.
49 *
50 * @hide
51 */
52 @SystemApi
Felipe Leme749b8892018-12-03 16:30:30 -080053 public static final class Builder {
Felipe Leme284ad1c2018-11-15 18:16:12 -080054
55 private FillWindow mFillWindow;
56
57 /**
58 * Sets the {@link FillWindow} used to display the Autofill UI.
59 *
60 * <p>Must be called when the service is handling the request so the Android System can
61 * properly synchronize the UI.
62 *
63 * @return this builder
64 */
65 public Builder setFillWindow(@NonNull FillWindow fillWindow) {
66 // TODO(b/111330312): implement / check not null / unit test
67 // TODO(b/111330312): throw exception if FillWindow not updated yet
68 mFillWindow = fillWindow;
69 return this;
70 }
71
72 /**
73 * Tells the Android System that the given {@code ids} should not trigger further
74 * {@link FillRequest requests} when focused.
75 *
76 * @param ids ids of the fields that should be ignored
77 *
78 * @return this builder
79 */
80 public Builder setIgnoredIds(@NonNull List<AutofillId> ids) {
81 // TODO(b/111330312): implement / check not null / unit test
82 return this;
83 }
84
85 /**
86 * Builds a new {@link FillResponse} instance.
87 *
88 * @throws IllegalStateException if any of the following conditions occur:
89 * <ol>
90 * <li>{@link #build()} was already called.
91 * <li>No call was made to {@link #setFillWindow(FillWindow)} or
92 * {@ling #setIgnoredIds(List<AutofillId>)}.
93 * </ol>
94 *
95 * @return A built response.
96 */
97 public FillResponse build() {
98 // TODO(b/111330312): check conditions / add unit test
99 return new FillResponse(this);
100 }
101
102 // TODO(b/111330312): add methods to disable app / activity, either here or on manager
103 }
104
105 @Override
106 public int describeContents() {
107 return 0;
108 }
109
110 @Override
111 public void writeToParcel(Parcel parcel, int flags) {
112 // TODO(b/111330312): implement
113 }
114
115 public static final Parcelable.Creator<FillResponse> CREATOR =
116 new Parcelable.Creator<FillResponse>() {
117
118 @Override
119 public FillResponse createFromParcel(Parcel parcel) {
120 // TODO(b/111330312): implement
121 return null;
122 }
123
124 @Override
125 public FillResponse[] newArray(int size) {
126 return new FillResponse[size];
127 }
128 };
129}