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.os.Bundle;
22 import android.service.autofill.Dataset;
23 
24 import com.android.internal.util.DataClass;
25 
26 import java.util.ArrayList;
27 import java.util.List;
28 
29 /**
30  * Response to a {@link FillRequest}.
31  *
32  * @hide
33  */
34 @SystemApi
35 @DataClass(
36         genBuilder = true,
37         genHiddenGetters = true)
38 public final class FillResponse {
39 
40     /**
41      * The {@link FillWindow} used to display the Autofill UI.
42      */
43     private @Nullable FillWindow mFillWindow;
44 
45     /**
46      * The {@link Dataset}s representing the inline suggestions data. Defaults to null if no
47      * inline suggestions are available from the service.
48      */
49     @DataClass.PluralOf("inlineSuggestion")
50     private @Nullable List<Dataset> mInlineSuggestions;
51 
52     /**
53      * The client state that {@link AugmentedAutofillService} implementation can put anything in to
54      * identify the request and the response when calling
55      * {@link AugmentedAutofillService#getFillEventHistory()}.
56      */
57     private @Nullable Bundle mClientState;
58 
defaultFillWindow()59     private static FillWindow defaultFillWindow() {
60         return null;
61     }
62 
defaultInlineSuggestions()63     private static List<Dataset> defaultInlineSuggestions() {
64         return null;
65     }
66 
defaultClientState()67     private static Bundle defaultClientState() {
68         return null;
69     }
70 
71 
72     /** @hide */
73     abstract static class BaseBuilder {
addInlineSuggestion(@onNull Dataset value)74         abstract FillResponse.Builder addInlineSuggestion(@NonNull Dataset value);
75     }
76 
77 
78 
79     // Code below generated by codegen v1.0.15.
80     //
81     // DO NOT MODIFY!
82     // CHECKSTYLE:OFF Generated code
83     //
84     // To regenerate run:
85     // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/autofill/augmented/FillResponse.java
86     //
87     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
88     //   Settings > Editor > Code Style > Formatter Control
89     //@formatter:off
90 
91 
92     @DataClass.Generated.Member
FillResponse( @ullable FillWindow fillWindow, @Nullable List<Dataset> inlineSuggestions, @Nullable Bundle clientState)93     /* package-private */ FillResponse(
94             @Nullable FillWindow fillWindow,
95             @Nullable List<Dataset> inlineSuggestions,
96             @Nullable Bundle clientState) {
97         this.mFillWindow = fillWindow;
98         this.mInlineSuggestions = inlineSuggestions;
99         this.mClientState = clientState;
100 
101         // onConstructed(); // You can define this method to get a callback
102     }
103 
104     /**
105      * The {@link FillWindow} used to display the Autofill UI.
106      *
107      * @hide
108      */
109     @DataClass.Generated.Member
getFillWindow()110     public @Nullable FillWindow getFillWindow() {
111         return mFillWindow;
112     }
113 
114     /**
115      * The {@link Dataset}s representing the inline suggestions data. Defaults to null if no
116      * inline suggestions are available from the service.
117      *
118      * @hide
119      */
120     @DataClass.Generated.Member
getInlineSuggestions()121     public @Nullable List<Dataset> getInlineSuggestions() {
122         return mInlineSuggestions;
123     }
124 
125     /**
126      * The client state that {@link AugmentedAutofillService} implementation can put anything in to
127      * identify the request and the response when calling
128      * {@link AugmentedAutofillService#getFillEventHistory()}.
129      *
130      * @hide
131      */
132     @DataClass.Generated.Member
getClientState()133     public @Nullable Bundle getClientState() {
134         return mClientState;
135     }
136 
137     /**
138      * A builder for {@link FillResponse}
139      */
140     @SuppressWarnings("WeakerAccess")
141     @DataClass.Generated.Member
142     public static final class Builder extends BaseBuilder {
143 
144         private @Nullable FillWindow mFillWindow;
145         private @Nullable List<Dataset> mInlineSuggestions;
146         private @Nullable Bundle mClientState;
147 
148         private long mBuilderFieldsSet = 0L;
149 
Builder()150         public Builder() {
151         }
152 
153         /**
154          * The {@link FillWindow} used to display the Autofill UI.
155          */
156         @DataClass.Generated.Member
setFillWindow(@onNull FillWindow value)157         public @NonNull Builder setFillWindow(@NonNull FillWindow value) {
158             checkNotUsed();
159             mBuilderFieldsSet |= 0x1;
160             mFillWindow = value;
161             return this;
162         }
163 
164         /**
165          * The {@link Dataset}s representing the inline suggestions data. Defaults to null if no
166          * inline suggestions are available from the service.
167          */
168         @DataClass.Generated.Member
setInlineSuggestions(@onNull List<Dataset> value)169         public @NonNull Builder setInlineSuggestions(@NonNull List<Dataset> value) {
170             checkNotUsed();
171             mBuilderFieldsSet |= 0x2;
172             mInlineSuggestions = value;
173             return this;
174         }
175 
176         /** @see #setInlineSuggestions */
177         @DataClass.Generated.Member
178         @Override
addInlineSuggestion(@onNull Dataset value)179         @NonNull FillResponse.Builder addInlineSuggestion(@NonNull Dataset value) {
180             if (mInlineSuggestions == null) setInlineSuggestions(new ArrayList<>());
181             mInlineSuggestions.add(value);
182             return this;
183         }
184 
185         /**
186          * The client state that {@link AugmentedAutofillService} implementation can put anything in to
187          * identify the request and the response when calling
188          * {@link AugmentedAutofillService#getFillEventHistory()}.
189          */
190         @DataClass.Generated.Member
setClientState(@onNull Bundle value)191         public @NonNull Builder setClientState(@NonNull Bundle value) {
192             checkNotUsed();
193             mBuilderFieldsSet |= 0x4;
194             mClientState = value;
195             return this;
196         }
197 
198         /** Builds the instance. This builder should not be touched after calling this! */
build()199         public @NonNull FillResponse build() {
200             checkNotUsed();
201             mBuilderFieldsSet |= 0x8; // Mark builder used
202 
203             if ((mBuilderFieldsSet & 0x1) == 0) {
204                 mFillWindow = defaultFillWindow();
205             }
206             if ((mBuilderFieldsSet & 0x2) == 0) {
207                 mInlineSuggestions = defaultInlineSuggestions();
208             }
209             if ((mBuilderFieldsSet & 0x4) == 0) {
210                 mClientState = defaultClientState();
211             }
212             FillResponse o = new FillResponse(
213                     mFillWindow,
214                     mInlineSuggestions,
215                     mClientState);
216             return o;
217         }
218 
checkNotUsed()219         private void checkNotUsed() {
220             if ((mBuilderFieldsSet & 0x8) != 0) {
221                 throw new IllegalStateException(
222                         "This Builder should not be reused. Use a new Builder instance instead");
223             }
224         }
225     }
226 
227     @DataClass.Generated(
228             time = 1584480900526L,
229             codegenVersion = "1.0.15",
230             sourceFile = "frameworks/base/core/java/android/service/autofill/augmented/FillResponse.java",
231             inputSignatures = "private @android.annotation.Nullable android.service.autofill.augmented.FillWindow mFillWindow\nprivate @com.android.internal.util.DataClass.PluralOf(\"inlineSuggestion\") @android.annotation.Nullable java.util.List<android.service.autofill.Dataset> mInlineSuggestions\nprivate @android.annotation.Nullable android.os.Bundle mClientState\nprivate static  android.service.autofill.augmented.FillWindow defaultFillWindow()\nprivate static  java.util.List<android.service.autofill.Dataset> defaultInlineSuggestions()\nprivate static  android.os.Bundle defaultClientState()\nclass FillResponse extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genBuilder=true, genHiddenGetters=true)\nabstract  android.service.autofill.augmented.FillResponse.Builder addInlineSuggestion(android.service.autofill.Dataset)\nclass BaseBuilder extends java.lang.Object implements []")
232     @Deprecated
__metadata()233     private void __metadata() {}
234 
235 
236     //@formatter:on
237     // End of generated code
238 
239 }
240