| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.service.autofill.augmented; |
| 17 |
|
| 18 |
import static android.service.autofill.augmented.AugmentedAutofillService.sDebug; |
| 19 |
|
| 20 |
import android.annotation.NonNull; |
| 21 |
import android.annotation.Nullable; |
| 22 |
import android.annotation.SystemApi; |
| 23 |
import android.os.Bundle; |
| 24 |
import android.service.autofill.Dataset; |
| 25 |
import android.service.autofill.augmented.AugmentedAutofillService.AutofillProxy; |
| 26 |
import android.util.Log; |
| 27 |
|
| 28 |
import java.util.List; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
@SystemApi |
| 36 |
public final class FillCallback { |
| 37 |
|
| 38 |
private static final String TAG = FillCallback.class.getSimpleName(); |
| 39 |
|
| 40 |
private final AutofillProxy mProxy; |
| 41 |
|
| 42 |
FillCallback(@NonNull AutofillProxy proxy) { |
| 43 |
mProxy = proxy; |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
public void onSuccess(@Nullable FillResponse response) { |
| 53 |
if (sDebug) Log.d(TAG, "onSuccess(): " + response); |
| 54 |
|
| 55 |
if (response == null) { |
| 56 |
mProxy.logEvent(AutofillProxy.REPORT_EVENT_NO_RESPONSE); |
| 57 |
mProxy.reportResult( null, |
| 58 |
null, false); |
| 59 |
return; |
| 60 |
} |
| 61 |
|
| 62 |
final List<Dataset> inlineSuggestions = response.getInlineSuggestions(); |
| 63 |
final Bundle clientState = response.getClientState(); |
| 64 |
final FillWindow fillWindow = response.getFillWindow(); |
| 65 |
boolean showingFillWindow = false; |
| 66 |
if (inlineSuggestions != null && !inlineSuggestions.isEmpty()) { |
| 67 |
mProxy.logEvent(AutofillProxy.REPORT_EVENT_INLINE_RESPONSE); |
| 68 |
} else if (fillWindow != null) { |
| 69 |
fillWindow.show(); |
| 70 |
showingFillWindow = true; |
| 71 |
} |
| 72 |
|
| 73 |
mProxy.reportResult(inlineSuggestions, clientState, showingFillWindow); |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
} |
| 79 |
} |