Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 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 | */ |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 16 | package android.service.autofill.augmented; |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 17 | |
| 18 | import android.annotation.NonNull; |
| 19 | import android.annotation.Nullable; |
| 20 | import android.annotation.SystemApi; |
Felipe Leme | 2cab38c | 2019-01-11 10:39:14 -0800 | [diff] [blame] | 21 | import android.annotation.TestApi; |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Response to a {@link FillRequest}. |
| 25 | * |
| 26 | * @hide |
| 27 | */ |
| 28 | @SystemApi |
Felipe Leme | 2cab38c | 2019-01-11 10:39:14 -0800 | [diff] [blame] | 29 | @TestApi |
Felipe Leme | 559e21d | 2019-01-18 17:57:21 -0800 | [diff] [blame] | 30 | public final class FillResponse { |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 31 | |
| 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 Leme | 2cab38c | 2019-01-11 10:39:14 -0800 | [diff] [blame] | 50 | @TestApi |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 51 | public static final class Builder { |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 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 | */ |
Felipe Leme | ce6877b | 2019-02-28 09:02:26 -0800 | [diff] [blame] | 63 | @NonNull |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 64 | public Builder setFillWindow(@NonNull FillWindow fillWindow) { |
Felipe Leme | 559e21d | 2019-01-18 17:57:21 -0800 | [diff] [blame] | 65 | // TODO(b/123100712): check not null / unit test / throw exception if FillWindow not |
| 66 | // updated yet |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 67 | mFillWindow = fillWindow; |
| 68 | return this; |
| 69 | } |
| 70 | |
| 71 | /** |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 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 | */ |
Felipe Leme | ce6877b | 2019-02-28 09:02:26 -0800 | [diff] [blame] | 83 | @NonNull |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 84 | public FillResponse build() { |
Felipe Leme | 559e21d | 2019-01-18 17:57:21 -0800 | [diff] [blame] | 85 | // TODO(b/123100712): check conditions / add unit test |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 86 | return new FillResponse(this); |
| 87 | } |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 88 | } |
| 89 | |
Felipe Leme | 559e21d | 2019-01-18 17:57:21 -0800 | [diff] [blame] | 90 | // TODO(b/123100811): implement to String |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 91 | } |