blob: 48a3c1b183348ec04e216b53a0cf2c119f56404e [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;
Felipe Leme2cab38c2019-01-11 10:39:14 -080021import android.annotation.TestApi;
Felipe Leme284ad1c2018-11-15 18:16:12 -080022
23/**
24 * Response to a {@link FillRequest}.
25 *
26 * @hide
27 */
28@SystemApi
Felipe Leme2cab38c2019-01-11 10:39:14 -080029@TestApi
Felipe Leme559e21d2019-01-18 17:57:21 -080030public final class FillResponse {
Felipe Leme284ad1c2018-11-15 18:16:12 -080031
32 private final FillWindow mFillWindow;
33
34 private FillResponse(@NonNull Builder builder) {
35 mFillWindow = builder.mFillWindow;
36 }
37
38 /** @hide */
39 @Nullable
40 FillWindow getFillWindow() {
41 return mFillWindow;
42 }
43
44 /**
45 * Builder for {@link FillResponse} objects.
46 *
47 * @hide
48 */
49 @SystemApi
Felipe Leme2cab38c2019-01-11 10:39:14 -080050 @TestApi
Felipe Leme749b8892018-12-03 16:30:30 -080051 public static final class Builder {
Felipe Leme284ad1c2018-11-15 18:16:12 -080052
53 private FillWindow mFillWindow;
54
55 /**
56 * Sets the {@link FillWindow} used to display the Autofill UI.
57 *
58 * <p>Must be called when the service is handling the request so the Android System can
59 * properly synchronize the UI.
60 *
61 * @return this builder
62 */
Felipe Lemece6877b2019-02-28 09:02:26 -080063 @NonNull
Felipe Leme284ad1c2018-11-15 18:16:12 -080064 public Builder setFillWindow(@NonNull FillWindow fillWindow) {
Felipe Leme559e21d2019-01-18 17:57:21 -080065 // TODO(b/123100712): check not null / unit test / throw exception if FillWindow not
66 // updated yet
Felipe Leme284ad1c2018-11-15 18:16:12 -080067 mFillWindow = fillWindow;
68 return this;
69 }
70
71 /**
Felipe Leme284ad1c2018-11-15 18:16:12 -080072 * Builds a new {@link FillResponse} instance.
73 *
74 * @throws IllegalStateException if any of the following conditions occur:
75 * <ol>
76 * <li>{@link #build()} was already called.
77 * <li>No call was made to {@link #setFillWindow(FillWindow)} or
78 * {@ling #setIgnoredIds(List<AutofillId>)}.
79 * </ol>
80 *
81 * @return A built response.
82 */
Felipe Lemece6877b2019-02-28 09:02:26 -080083 @NonNull
Felipe Leme284ad1c2018-11-15 18:16:12 -080084 public FillResponse build() {
Felipe Leme559e21d2019-01-18 17:57:21 -080085 // TODO(b/123100712): check conditions / add unit test
Felipe Leme284ad1c2018-11-15 18:16:12 -080086 return new FillResponse(this);
87 }
Felipe Leme284ad1c2018-11-15 18:16:12 -080088 }
89
Felipe Leme559e21d2019-01-18 17:57:21 -080090 // TODO(b/123100811): implement to String
Felipe Leme284ad1c2018-11-15 18:16:12 -080091}