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 | */ |
| 16 | package android.service.intelligence; |
| 17 | |
Felipe Leme | bf93cdc | 2018-12-03 12:05:58 -0800 | [diff] [blame] | 18 | import android.annotation.NonNull; |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 19 | import android.annotation.Nullable; |
| 20 | import android.annotation.SystemApi; |
Felipe Leme | bf93cdc | 2018-12-03 12:05:58 -0800 | [diff] [blame] | 21 | import android.service.intelligence.SmartSuggestionsService.AutofillProxy; |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Callback used to indicate at {@link FillRequest} has been fulfilled. |
| 25 | * |
| 26 | * @hide |
| 27 | */ |
| 28 | @SystemApi |
| 29 | public final class FillCallback { |
Felipe Leme | bf93cdc | 2018-12-03 12:05:58 -0800 | [diff] [blame] | 30 | private final AutofillProxy mProxy; |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 31 | |
Felipe Leme | bf93cdc | 2018-12-03 12:05:58 -0800 | [diff] [blame] | 32 | FillCallback(@NonNull AutofillProxy proxy) { |
| 33 | mProxy = proxy; |
| 34 | } |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Sets the response associated with the request. |
| 38 | * |
| 39 | * @param response response associated with the request, or {@code null} if the service |
| 40 | * could not provide autofill for the request. |
| 41 | */ |
| 42 | public void onSuccess(@Nullable FillResponse response) { |
Felipe Leme | bf93cdc | 2018-12-03 12:05:58 -0800 | [diff] [blame] | 43 | mProxy.report(AutofillProxy.REPORT_EVENT_ON_SUCCESS); |
Felipe Leme | 284ad1c | 2018-11-15 18:16:12 -0800 | [diff] [blame] | 44 | final FillWindow fillWindow = response.getFillWindow(); |
| 45 | if (fillWindow != null) { |
| 46 | fillWindow.show(); |
| 47 | } |
| 48 | // TODO(b/111330312): properly implement on server-side by updating the Session state |
| 49 | // accordingly (and adding CTS tests) |
| 50 | } |
| 51 | } |