• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 package android.service.autofill.augmented;
17 
18 import android.annotation.NonNull;
19 import android.annotation.Nullable;
20 import android.annotation.SystemApi;
21 import android.annotation.TestApi;
22 
23 /**
24  * Response to a {@link FillRequest}.
25  *
26  * @hide
27  */
28 @SystemApi
29 @TestApi
30 public final class FillResponse {
31 
32     private final FillWindow mFillWindow;
33 
FillResponse(@onNull Builder builder)34     private FillResponse(@NonNull Builder builder) {
35         mFillWindow = builder.mFillWindow;
36     }
37 
38     /** @hide */
39     @Nullable
getFillWindow()40     FillWindow getFillWindow() {
41         return mFillWindow;
42     }
43 
44     /**
45      * Builder for {@link FillResponse} objects.
46      *
47      * @hide
48      */
49     @SystemApi
50     @TestApi
51     public static final class Builder {
52 
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          */
63         @NonNull
setFillWindow(@onNull FillWindow fillWindow)64         public Builder setFillWindow(@NonNull FillWindow fillWindow) {
65             // TODO(b/123100712): check not null / unit test / throw exception if FillWindow not
66             // updated yet
67             mFillWindow = fillWindow;
68             return this;
69         }
70 
71         /**
72          * 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          */
83         @NonNull
build()84         public FillResponse build() {
85             // TODO(b/123100712): check conditions / add unit test
86             return new FillResponse(this);
87         }
88     }
89 
90     // TODO(b/123100811): implement to String
91 }
92