/
AutofillService.xml
1097 lines (1076 loc) · 79.1 KB
/
AutofillService.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<Type Name="AutofillService" FullName="Android.Service.Autofill.AutofillService">
<TypeSignature Language="C#" Value="public abstract class AutofillService : Android.App.Service" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract beforefieldinit AutofillService extends Android.App.Service" />
<TypeSignature Language="DocId" Value="T:Android.Service.Autofill.AutofillService" />
<TypeSignature Language="F#" Value="type AutofillService = class
 inherit Service" />
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>Android.App.Service</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.Register("android/service/autofill/AutofillService", ApiSince=26, DoNotGenerateAcw=true)]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.Register("android/service/autofill/AutofillService", ApiSince=26, DoNotGenerateAcw=true)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Runtime.Versioning.SupportedOSPlatform("android26.0")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.SupportedOSPlatform("android26.0")>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>An <c>AutofillService</c> is a service used to automatically fill the contents of the screen
on behalf of a given user - for more information about autofill, read
<see href="https://developer.android.com/preview/features/autofill.html">Autofill Framework</see>.</summary>
<remarks>
<para>An <c>AutofillService</c> is a service used to automatically fill the contents of the screen
on behalf of a given user - for more information about autofill, read
<see href="https://developer.android.com/preview/features/autofill.html">Autofill Framework</see>.</para>
<para>An <c>AutofillService</c> is only bound to the Android System for autofill purposes if:
<ol>
<li>It requires the <c>android.permission.BIND_AUTOFILL_SERVICE</c> permission in its
manifest.
<li>The user explicitly enables it using Android Settings (the
<c>Settings#ACTION_REQUEST_SET_AUTOFILL_SERVICE</c> intent can be used to launch such
Settings screen).
</ol>
"BasicUsage"><h3>Basic usage</h3></para>
<para>The basic autofill process is defined by the workflow below:
<ol>
<li>User focus an editable <c>View</c>.
<li>View calls <c>AutofillManager#notifyViewEntered(android.view.View)</c>.
<li>A <c>ViewStructure</c> representing all views in the screen is created.
<li>The Android System binds to the service and calls <c>#onConnected()</c>.
<li>The service receives the view structure through the
<c>#onFillRequest(FillRequest, CancellationSignal, FillCallback)</c>.
<li>The service replies through <c>FillCallback#onSuccess(FillResponse)</c>.
<li>The Android System calls <c>#onDisconnected()</c> and unbinds from the
<c>AutofillService</c>.
<li>The Android System displays an autofill UI with the options sent by the service.
<li>The user picks an option.
<li>The proper views are autofilled.
</ol></para>
<para>This workflow was designed to minimize the time the Android System is bound to the service;
for each call, it: binds to service, waits for the reply, and unbinds right away. Furthermore,
those calls are considered stateless: if the service needs to keep state between calls, it must
do its own state management (keeping in mind that the service's process might be killed by the
Android System when unbound; for example, if the device is running low in memory).</para>
<para>Typically, the
<c>#onFillRequest(FillRequest, CancellationSignal, FillCallback)</c> will:
<ol>
<li>Parse the view structure looking for autofillable views (for example, using
<c>android.app.assist.AssistStructure.ViewNode#getAutofillHints()</c>.
<li>Match the autofillable views with the user's data.
<li>Create a <c>Dataset</c> for each set of user's data that match those fields.
<li>Fill the dataset(s) with the proper <c>AutofillId</c>s and <c>AutofillValue</c>s.
<li>Add the dataset(s) to the <c>FillResponse</c> passed to
<c>FillCallback#onSuccess(FillResponse)</c>.
</ol></para>
<para>For example, for a login screen with username and password views where the user only has one
account in the service, the response could be:</para>
<code lang="text/java">new FillResponse.Builder()
.addDataset(new Dataset.Builder()
.setValue(id1, AutofillValue.forText("homer"), createPresentation("homer"))
.setValue(id2, AutofillValue.forText("D'OH!"), createPresentation("password for homer"))
.build())
.build();
</code>
<para>But if the user had 2 accounts instead, the response could be:</para>
<code lang="text/java">new FillResponse.Builder()
.addDataset(new Dataset.Builder()
.setValue(id1, AutofillValue.forText("homer"), createPresentation("homer"))
.setValue(id2, AutofillValue.forText("D'OH!"), createPresentation("password for homer"))
.build())
.addDataset(new Dataset.Builder()
.setValue(id1, AutofillValue.forText("flanders"), createPresentation("flanders"))
.setValue(id2, AutofillValue.forText("OkelyDokelyDo"), createPresentation("password for flanders"))
.build())
.build();
</code>
<para>If the service does not find any autofillable view in the view structure, it should pass
<c>null</c> to <c>FillCallback#onSuccess(FillResponse)</c>; if the service encountered an error
processing the request, it should call <c>FillCallback#onFailure(CharSequence)</c>. For
performance reasons, it's paramount that the service calls either
<c>FillCallback#onSuccess(FillResponse)</c> or <c>FillCallback#onFailure(CharSequence)</c> for
each <c>#onFillRequest(FillRequest, CancellationSignal, FillCallback)</c> received - if it
doesn't, the request will eventually time out and be discarded by the Android System.
"SavingUserData"><h3>Saving user data</h3></para>
<para>If the service is also interested on saving the data filled by the user, it must set a
<c>SaveInfo</c> object in the <c>FillResponse</c>. See <c>SaveInfo</c> for more details and
examples.
"UserAuthentication"><h3>User authentication</h3></para>
<para>The service can provide an extra degree of security by requiring the user to authenticate
before an app can be autofilled. The authentication is typically required in 2 scenarios:
<ul>
<li>To unlock the user data (for example, using a main password or fingerprint
authentication) - see
<c>FillResponse.Builder#setAuthentication(AutofillId[], android.content.IntentSender, android.widget.RemoteViews)</c>.
<li>To unlock a specific dataset (for example, by providing a CVC for a credit card) - see
<c>Dataset.Builder#setAuthentication(android.content.IntentSender)</c>.
</ul></para>
<para>When using authentication, it is recommended to encrypt only the sensitive data and leave
labels unencrypted, so they can be used on presentation views. For example, if the user has a
home and a work address, the <c>Home</c> and <c>Work</c> labels should be stored unencrypted
(since they don't have any sensitive data) while the address data per se could be stored in an
encrypted storage. Then when the user chooses the <c>Home</c> dataset, the platform starts
the authentication flow, and the service can decrypt the sensitive data.</para>
<para>The authentication mechanism can also be used in scenarios where the service needs multiple
steps to determine the datasets that can fill a screen. For example, when autofilling a financial
app where the user has accounts for multiple banks, the workflow could be:
<ol>
<li>The first <c>FillResponse</c> contains datasets with the credentials for the financial
app, plus a "fake" dataset whose presentation says "Tap here for banking apps credentials".
<li>When the user selects the fake dataset, the service displays a dialog with available
banking apps.
<li>When the user select a banking app, the service replies with a new <c>FillResponse</c>
containing the datasets for that bank.
</ol></para>
<para>Another example of multiple-steps dataset selection is when the service stores the user
credentials in "vaults": the first response would contain fake datasets with the vault names,
and the subsequent response would contain the app credentials stored in that vault.
"DataPartioning"><h3>Data partitioning</h3></para>
<para>The autofillable views in a screen should be grouped in logical groups called "partitions".
Typical partitions are:
<ul>
<li>Credentials (username/email address, password).
<li>Address (street, city, state, zip code, etc).
<li>Payment info (credit card number, expiration date, and verification code).
</ul></para>
<para>For security reasons, when a screen has more than one partition, it's paramount that the
contents of a dataset do not spawn multiple partitions, specially when one of the partitions
contains data that is not specific to the application being autofilled. For example, a dataset
should not contain fields for username, password, and credit card information. The reason for
this rule is that a malicious app could draft a view structure where the credit card fields
are not visible, so when the user selects a dataset from the username UI, the credit card info is
released to the application without the user knowledge. Similarly, it's recommended to always
protect a dataset that contains sensitive information by requiring dataset authentication
(see <c>Dataset.Builder#setAuthentication(android.content.IntentSender)</c>), and to include
info about the "primary" field of the partition in the custom presentation for "secondary"
fields&mdash;that would prevent a malicious app from getting the "primary" fields without the
user realizing they're being released (for example, a malicious app could have fields for a
credit card number, verification code, and expiration date crafted in a way that just the latter
is visible; by explicitly indicating the expiration date is related to a given credit card
number, the service would be providing a visual clue for the users to check what would be
released upon selecting that field).</para>
<para>When the service detects that a screen has multiple partitions, it should return a
<c>FillResponse</c> with just the datasets for the partition that originated the request (i.e.,
the partition that has the <c>android.app.assist.AssistStructure.ViewNode</c> whose
<c>android.app.assist.AssistStructure.ViewNode#isFocused()</c> returns <c>true</c>); then if
the user selects a field from a different partition, the Android System will make another
<c>#onFillRequest(FillRequest, CancellationSignal, FillCallback)</c> call for that partition,
and so on.</para>
<para>Notice that when the user autofill a partition with the data provided by the service and the
user did not change these fields, the autofilled value is sent back to the service in the
subsequent calls (and can be obtained by calling
<c>android.app.assist.AssistStructure.ViewNode#getAutofillValue()</c>). This is useful in the
cases where the service must create datasets for a partition based on the choice made in a
previous partition. For example, the 1st response for a screen that have credentials and address
partitions could be:</para>
<code lang="text/java">new FillResponse.Builder()
.addDataset(new Dataset.Builder() // partition 1 (credentials)
.setValue(id1, AutofillValue.forText("homer"), createPresentation("homer"))
.setValue(id2, AutofillValue.forText("D'OH!"), createPresentation("password for homer"))
.build())
.addDataset(new Dataset.Builder() // partition 1 (credentials)
.setValue(id1, AutofillValue.forText("flanders"), createPresentation("flanders"))
.setValue(id2, AutofillValue.forText("OkelyDokelyDo"), createPresentation("password for flanders"))
.build())
.setSaveInfo(new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_PASSWORD,
new AutofillId[] { id1, id2 })
.build())
.build();
</code>
<para>Then if the user selected <c>flanders</c>, the service would get a new
<c>#onFillRequest(FillRequest, CancellationSignal, FillCallback)</c> call, with the values of
the fields <c>id1</c> and <c>id2</c> prepopulated, so the service could then fetch the address
for the Flanders account and return the following <c>FillResponse</c> for the address partition:</para>
<code lang="text/java">new FillResponse.Builder()
.addDataset(new Dataset.Builder() // partition 2 (address)
.setValue(id3, AutofillValue.forText("744 Evergreen Terrace"), createPresentation("744 Evergreen Terrace")) // street
.setValue(id4, AutofillValue.forText("Springfield"), createPresentation("Springfield")) // city
.build())
.setSaveInfo(new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_PASSWORD | SaveInfo.SAVE_DATA_TYPE_ADDRESS,
new AutofillId[] { id1, id2 }) // username and password
.setOptionalIds(new AutofillId[] { id3, id4 }) // state and zipcode
.build())
.build();
</code>
<para>When the service returns multiple <c>FillResponse</c>, the last one overrides the previous;
that's why the <c>SaveInfo</c> in the 2nd request above has the info for both partitions.
"PackageVerification"><h3>Package verification</h3></para>
<para>When autofilling app-specific data (like username and password), the service must verify
the authenticity of the request by obtaining all signing certificates of the app being
autofilled, and only fulfilling the request when they match the values that were
obtained when the data was first saved &mdash; such verification is necessary to avoid phishing
attempts by apps that were sideloaded in the device with the same package name of another app.
Here's an example on how to achieve that by hashing the signing certificates:</para>
<code lang="text/java">private String getCertificatesHash(String packageName) throws Exception {
PackageManager pm = mContext.getPackageManager();
PackageInfo info = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
ArrayList<String> hashes = new ArrayList<>(info.signatures.length);
for (Signature sig : info.signatures) {
byte[] cert = sig.toByteArray();
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(cert);
hashes.add(toHexString(md.digest()));
}
Collections.sort(hashes);
StringBuilder hash = new StringBuilder();
for (int i = 0; i < hashes.size(); i++) {
hash.append(hashes.get(i));
}
return hash.toString();
}
</code>
<para>If the service did not store the signing certificates data the first time the data was saved
&mdash; for example, because the data was created by a previous version of the app that did not
use the Autofill Framework &mdash; the service should warn the user that the authenticity of the
app cannot be confirmed (see an example on how to show such warning in the
Web security section below), and if the user agrees,
then the service could save the data from the signing ceriticates for future use.
"IgnoringViews"><h3>Ignoring views</h3></para>
<para>If the service find views that cannot be autofilled (for example, a text field representing
the response to a Captcha challenge), it should mark those views as ignored by
calling <c>FillResponse.Builder#setIgnoredIds(AutofillId...)</c> so the system does not trigger
a new <c>#onFillRequest(FillRequest, CancellationSignal, FillCallback)</c> when these views are
focused.
"WebSecurity"><h3>Web security</h3></para>
<para>When handling autofill requests that represent web pages (typically
view structures whose root's <c>android.app.assist.AssistStructure.ViewNode#getClassName()</c>
is a <c>android.webkit.WebView</c>), the service should take the following steps to verify if
the structure can be autofilled with the data associated with the app requesting it:
<ol>
<li>Use the <c>android.app.assist.AssistStructure.ViewNode#getWebDomain()</c> to get the
source of the document.
<li>Get the canonical domain using the
<see href="https://publicsuffix.org/">Public Suffix List</see> (see example below).
<li>Use <see href="https://developers.google.com/digital-asset-links/">Digital Asset Links</see>
to obtain the package name and certificate fingerprint of the package corresponding to
the canonical domain.
<li>Make sure the certificate fingerprint matches the value returned by Package Manager
(see "Package verification" section above).
</ol></para>
<para>Here's an example on how to get the canonical domain using
<see href="https://github.com/google/guava">Guava</see>:</para>
<code lang="text/java">private static String getCanonicalDomain(String domain) {
InternetDomainName idn = InternetDomainName.from(domain);
while (idn != null && !idn.isTopPrivateDomain()) {
idn = idn.parent();
}
return idn == null ? null : idn.toString();
}
</code>
<para>"WebSecurityDisclaimer"></para>
<para>If the association between the web domain and app package cannot be verified through the steps
above, but the service thinks that it is appropriate to fill persisted credentials that are
stored for the web domain, the service should warn the user about the potential data
leakage first, and ask for the user to confirm. For example, the service could:
<ol>
<li>Create a dataset that requires
<c>Dataset.Builder#setAuthentication(android.content.IntentSender) authentication</c> to
unlock.
<li>Include the web domain in the custom presentation for the
<c>Dataset.Builder#setValue(AutofillId, AutofillValue, android.widget.RemoteViews)
dataset value</c>.
<li>When the user selects that dataset, show a disclaimer dialog explaining that the app is
requesting credentials for a web domain, but the service could not verify if the app owns
that domain. If the user agrees, then the service can unlock the dataset.
<li>Similarly, when adding a <c>SaveInfo</c> object for the request, the service should
include the above disclaimer in the <c>SaveInfo.Builder#setDescription(CharSequence)</c>.
</ol></para>
<para>This same procedure could also be used when the autofillable data is contained inside an
<c>IFRAME</c>, in which case the WebView generates a new autofill context when a node inside
the <c>IFRAME</c> is focused, with the root node containing the <c>IFRAME</c>'s <c>src</c>
attribute on <c>android.app.assist.AssistStructure.ViewNode#getWebDomain()</c>. A typical and
legitimate use case for this scenario is a financial app that allows the user
to login on different bank accounts. For example, a financial app <c>my_financial_app</c> could
use a WebView that loads contents from <c>banklogin.my_financial_app.com</c>, which contains an
<c>IFRAME</c> node whose <c>src</c> attribute is <c>login.some_bank.com</c>. When fulfilling
that request, the service could add an
<c>Dataset.Builder#setAuthentication(android.content.IntentSender) authenticated dataset</c>
whose presentation displays "Username for some_bank.com" and
"Password for some_bank.com". Then when the user taps one of these options, the service
shows the disclaimer dialog explaining that selecting that option would release the
<c>login.some_bank.com</c> credentials to the <c>my_financial_app</c>; if the user agrees,
then the service returns an unlocked dataset with the <c>some_bank.com</c> credentials.</para>
<para><b>Note:</b> The autofill service could also add well-known browser apps into an allowlist and
skip the verifications above, as long as the service can verify the authenticity of the browser
app by checking its signing certificate.
"MultipleStepsSave"><h3>Saving when data is split in multiple screens</h3>
Apps often split the user data in multiple screens in the same activity, specially in
activities used to create a new user account. For example, the first screen asks for a username,
and if the username is available, it moves to a second screen, which asks for a password.</para>
<para>It's tricky to handle save for autofill in these situations, because the autofill service must
wait until the user enters both fields before the autofill save UI can be shown. But it can be
done by following the steps below:
<ol>
<li>In the first
<c>#onFillRequest(FillRequest, CancellationSignal, FillCallback) fill request</c>, the service
adds a <c>FillResponse.Builder#setClientState(android.os.Bundle) client state bundle</c> in
the response, containing the autofill ids of the partial fields present in the screen.
<li>In the second
<c>#onFillRequest(FillRequest, CancellationSignal, FillCallback) fill request</c>, the service
retrieves the <c>FillRequest#getClientState() client state bundle</c>, gets the autofill ids
set in the previous request from the client state, and adds these ids and the
<c>SaveInfo#FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE</c> to the <c>SaveInfo</c> used in the second
response.
<li>In the <c>#onSaveRequest(SaveRequest, SaveCallback) save request</c>, the service uses the
proper <c>FillContext fill contexts</c> to get the value of each field (there is one fill
context per fill request).
</ol></para>
<para>For example, in an app that uses 2 steps for the username and password fields, the workflow
would be:</para>
<code lang="text/java">// On first fill request
AutofillId usernameId = // parse from AssistStructure;
Bundle clientState = new Bundle();
clientState.putParcelable("usernameId", usernameId);
fillCallback.onSuccess(
new FillResponse.Builder()
.setClientState(clientState)
.setSaveInfo(new SaveInfo
.Builder(SaveInfo.SAVE_DATA_TYPE_USERNAME, new AutofillId[] {usernameId})
.build())
.build());
// On second fill request
Bundle clientState = fillRequest.getClientState();
AutofillId usernameId = clientState.getParcelable("usernameId");
AutofillId passwordId = // parse from AssistStructure
clientState.putParcelable("passwordId", passwordId);
fillCallback.onSuccess(
new FillResponse.Builder()
.setClientState(clientState)
.setSaveInfo(new SaveInfo
.Builder(SaveInfo.SAVE_DATA_TYPE_USERNAME | SaveInfo.SAVE_DATA_TYPE_PASSWORD,
new AutofillId[] {usernameId, passwordId})
.setFlags(SaveInfo.FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE)
.build())
.build());
// On save request
Bundle clientState = saveRequest.getClientState();
AutofillId usernameId = clientState.getParcelable("usernameId");
AutofillId passwordId = clientState.getParcelable("passwordId");
List<FillContext> fillContexts = saveRequest.getFillContexts();
FillContext usernameContext = fillContexts.get(0);
ViewNode usernameNode = findNodeByAutofillId(usernameContext.getStructure(), usernameId);
AutofillValue username = usernameNode.getAutofillValue().getTextValue().toString();
FillContext passwordContext = fillContexts.get(1);
ViewNode passwordNode = findNodeByAutofillId(passwordContext.getStructure(), passwordId);
AutofillValue password = passwordNode.getAutofillValue().getTextValue().toString();
save(username, password);
</code>
<para>"Privacy"><h3>Privacy</h3></para>
<para>The <c>#onFillRequest(FillRequest, CancellationSignal, FillCallback)</c> method is called
without the user content. The Android system strips some properties of the
<c>android.app.assist.AssistStructure.ViewNode view nodes</c> passed to this call, but not all
of them. For example, the data provided in the <c>android.view.ViewStructure.HtmlInfo</c>
objects set by <c>android.webkit.WebView</c> is never stripped out.</para>
<para>Because this data could contain PII (Personally Identifiable Information, such as username or
email address), the service should only use it locally (i.e., in the app's process) for
heuristics purposes, but it should not be sent to external servers.
"FieldClassification"><h3>Metrics and field classification</h3></para>
<para>The service can call <c>#getFillEventHistory()</c> to get metrics representing the user
actions, and then use these metrics to improve its heuristics.</para>
<para>Prior to Android <c>android.os.Build.VERSION_CODES#P</c>, the metrics covered just the
scenarios where the service knew how to autofill an activity, but Android
<c>android.os.Build.VERSION_CODES#P</c> introduced a new mechanism called field classification,
which allows the service to dynamically classify the meaning of fields based on the existing user
data known by the service.</para>
<para>Typically, field classification can be used to detect fields that can be autofilled with
user data that is not associated with a specific app&mdash;such as email and physical
address. Once the service identifies that a such field was manually filled by the user, the
service could use this signal to improve its heuristics on subsequent requests (for example, by
infering which resource ids are associated with known fields).</para>
<para>The field classification workflow involves 4 steps:
<ol>
<li>Set the user data through <c>AutofillManager#setUserData(UserData)</c>. This data is
cached until the system restarts (or the service is disabled), so it doesn't need to be set for
all requests.
<li>Identify which fields should be analysed by calling
<c>FillResponse.Builder#setFieldClassificationIds(AutofillId...)</c>.
<li>Verify the results through <c>FillEventHistory.Event#getFieldsClassification()</c>.
<li>Use the results to dynamically create <c>Dataset</c> or <c>SaveInfo</c> objects in
subsequent requests.
</ol></para>
<para>The field classification is an expensive operation and should be used carefully, otherwise it
can reach its rate limit and get blocked by the Android System. Ideally, it should be used just
in cases where the service could not determine how an activity can be autofilled, but it has a
strong suspicious that it could. For example, if an activity has four or more fields and one of
them is a list, chances are that these are address fields (like address, city, state, and
zip code).
"CompatibilityMode"><h3>Compatibility mode</h3></para>
<para>Apps that use standard Android widgets support autofill out-of-the-box and need to do
very little to improve their user experience (annotating autofillable views and providing
autofill hints). However, some apps (typically browsers) do their own rendering and the rendered
content may contain semantic structure that needs to be surfaced to the autofill framework. The
platform exposes APIs to achieve this, however it could take some time until these apps implement
autofill support.</para>
<para>To enable autofill for such apps the platform provides a compatibility mode in which the
platform would fall back to the accessibility APIs to generate the state reported to autofill
services and fill data. This mode needs to be explicitly requested for a given package up
to a specified max version code allowing clean migration path when the target app begins to
support autofill natively. Note that enabling compatibility may degrade performance for the
target package and should be used with caution. The platform supports creating an allowlist for
including which packages can be targeted in compatibility mode to ensure this mode is used only
when needed and as long as needed.</para>
<para>You can request compatibility mode for packages of interest in the meta-data resource
associated with your service. Below is a sample service declaration:</para>
<code lang="text/java">&lt;service android:name=".MyAutofillService"
android:permission="android.permission.BIND_AUTOFILL_SERVICE"&gt;
&lt;intent-filter&gt;
&lt;action android:name="android.service.autofill.AutofillService" /&gt;
&lt;/intent-filter&gt;
&lt;meta-data android:name="android.autofill" android:resource="@xml/autofillservice" /&gt;
&lt;/service&gt;</code>
<para>In the XML file you can specify one or more packages for which to enable compatibility
mode. Below is a sample meta-data declaration:</para>
<code lang="text/java">&lt;autofill-service xmlns:android="http://schemas.android.com/apk/res/android"&gt;
&lt;compatibility-package android:name="foo.bar.baz" android:maxLongVersionCode="1000000000"/&gt;
&lt;/autofill-service&gt;</code>
<para>Notice that compatibility mode has limitations such as:
<ul>
<li>No manual autofill requests. Hence, the <c>FillRequest</c><c>FillRequest#getFlags() flags</c> never have the <c>FillRequest#FLAG_MANUAL_REQUEST</c> flag.
<li>The value of password fields are most likely masked&mdash;for example, <c>****</c> instead
of <c>1234</c>. Hence, you must be careful when using these values to avoid updating the user
data with invalid input. For example, when you parse the <c>FillRequest</c> and detect a
password field, you could check if its
<c>android.app.assist.AssistStructure.ViewNode#getInputType()
input type</c> has password flags and if so, don't add it to the <c>SaveInfo</c> object.
<li>The autofill context is not always <c>AutofillManager#commit() committed</c> when an HTML
form is submitted. Hence, you must use other mechanisms to trigger save, such as setting the
<c>SaveInfo#FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE</c> flag on <c>SaveInfo.Builder#setFlags(int)</c>
or using <c>SaveInfo.Builder#setTriggerId(AutofillId)</c>.
<li>Browsers often provide their own autofill management system. When both the browser and
the platform render an autofill dialog at the same time, the result can be confusing to the user.
Such browsers typically offer an option for users to disable autofill, so your service should
also allow users to disable compatiblity mode for specific apps. That way, it is up to the user
to decide which autofill mechanism&mdash;the browser's or the platform's&mdash;should be used.
</ul></para>
<para>
<format type="text/html">
<a href="https://developer.android.com/reference/android/service/autofill/AutofillService" title="Reference documentation">Java documentation for <code>android.service.autofill.AutofillService</code>.</a>
</format>
</para>
<para>
Portions of this page are modifications based on work created and shared by the
<format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format>
and used according to terms described in the
<format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public AutofillService ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:Android.Service.Autofill.AutofillService.#ctor" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.Register(".ctor", "()V", "", ApiSince=26)]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.Register(".ctor", "()V", "", ApiSince=26)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Runtime.Versioning.SupportedOSPlatform("android26.0")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.SupportedOSPlatform("android26.0")>]</AttributeName>
</Attribute>
</Attributes>
<Parameters />
<Docs>
<summary>To be added.</summary>
<remarks>
<para>Portions of this page are modifications based on work created and shared by the <format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format> and used according to terms described in the <format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="protected AutofillService (IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig specialname rtspecialname instance void .ctor(native int javaReference, valuetype Android.Runtime.JniHandleOwnership transfer) cil managed" />
<MemberSignature Language="DocId" Value="M:Android.Service.Autofill.AutofillService.#ctor(System.IntPtr,Android.Runtime.JniHandleOwnership)" />
<MemberSignature Language="F#" Value="new Android.Service.Autofill.AutofillService : nativeint * Android.Runtime.JniHandleOwnership -> Android.Service.Autofill.AutofillService" Usage="new Android.Service.Autofill.AutofillService (javaReference, transfer)" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="javaReference" Type="System.IntPtr" />
<Parameter Name="transfer" Type="Android.Runtime.JniHandleOwnership" />
</Parameters>
<Docs>
<param name="javaReference">To be added.</param>
<param name="transfer">To be added.</param>
<summary>To be added.</summary>
<remarks>
<para>Portions of this page are modifications based on work created and shared by the <format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format> and used according to terms described in the <format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
</Docs>
</Member>
<Member MemberName="ExtraFillResponse">
<MemberSignature Language="C#" Value="public const string ExtraFillResponse;" />
<MemberSignature Language="ILAsm" Value=".field public static literal string ExtraFillResponse" />
<MemberSignature Language="DocId" Value="F:Android.Service.Autofill.AutofillService.ExtraFillResponse" />
<MemberSignature Language="F#" Value="val mutable ExtraFillResponse : string" Usage="Android.Service.Autofill.AutofillService.ExtraFillResponse" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.Register("EXTRA_FILL_RESPONSE", ApiSince=33)]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.Register("EXTRA_FILL_RESPONSE", ApiSince=33)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Runtime.Versioning.SupportedOSPlatform("android33.0")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.SupportedOSPlatform("android33.0")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Name of the <c>FillResponse</c> extra used to return a delayed fill response.</summary>
<remarks>
<para>Name of the <c>FillResponse</c> extra used to return a delayed fill response.</para>
<para>Please see <c>FillRequest#getDelayedFillIntentSender()</c> on how to send a delayed
fill response to framework.</para>
<para>
<format type="text/html">
<a href="https://developer.android.com/reference/android/service/autofill/AutofillService#EXTRA_FILL_RESPONSE" title="Reference documentation">Java documentation for <code>android.service.autofill.AutofillService.EXTRA_FILL_RESPONSE</code>.</a>
</format>
</para>
<para>
Portions of this page are modifications based on work created and shared by the
<format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format>
and used according to terms described in the
<format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
</Docs>
</Member>
<Member MemberName="FillEventHistory">
<MemberSignature Language="C#" Value="public Android.Service.Autofill.FillEventHistory? FillEventHistory { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class Android.Service.Autofill.FillEventHistory FillEventHistory" />
<MemberSignature Language="DocId" Value="P:Android.Service.Autofill.AutofillService.FillEventHistory" />
<MemberSignature Language="F#" Value="member this.FillEventHistory : Android.Service.Autofill.FillEventHistory" Usage="Android.Service.Autofill.AutofillService.FillEventHistory" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.Runtime.Versioning.SupportedOSPlatform("android26.0")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.SupportedOSPlatform("android26.0")>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[get: Android.Runtime.Register("getFillEventHistory", "()Landroid/service/autofill/FillEventHistory;", "", ApiSince=26)]</AttributeName>
<AttributeName Language="F#">[<get: Android.Runtime.Register("getFillEventHistory", "()Landroid/service/autofill/FillEventHistory;", "", ApiSince=26)>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>Android.Service.Autofill.FillEventHistory</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the events that happened after the last
<c>AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, FillCallback)</c>
call.</summary>
<value>The history or <c>null</c> if there are no events.</value>
<remarks>
<para>Gets the events that happened after the last
<c>AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, FillCallback)</c>
call.</para>
<para>This method is typically used to keep track of previous user actions to optimize further
requests. For example, the service might return email addresses in alphabetical order by
default, but change that order based on the address the user picked on previous requests.</para>
<para>The history is not persisted over reboots, and it's cleared every time the service
replies to a <c>#onFillRequest(FillRequest, CancellationSignal, FillCallback)</c> by calling
<c>FillCallback#onSuccess(FillResponse)</c> or <c>FillCallback#onFailure(CharSequence)</c>
(if the service doesn't call any of these methods, the history will clear out after some
pre-defined time). Hence, the service should call <c>#getFillEventHistory()</c> before
finishing the <c>FillCallback</c>.</para>
<para>
<format type="text/html">
<a href="https://developer.android.com/reference/android/service/autofill/AutofillService#getFillEventHistory()" title="Reference documentation">Java documentation for <code>android.service.autofill.AutofillService.getFillEventHistory()</code>.</a>
</format>
</para>
<para>
Portions of this page are modifications based on work created and shared by the
<format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format>
and used according to terms described in the
<format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
</Docs>
</Member>
<Member MemberName="JniPeerMembers">
<MemberSignature Language="C#" Value="public override Java.Interop.JniPeerMembers JniPeerMembers { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class Java.Interop.JniPeerMembers JniPeerMembers" />
<MemberSignature Language="DocId" Value="P:Android.Service.Autofill.AutofillService.JniPeerMembers" />
<MemberSignature Language="F#" Value="member this.JniPeerMembers : Java.Interop.JniPeerMembers" Usage="Android.Service.Autofill.AutofillService.JniPeerMembers" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]</AttributeName>
<AttributeName Language="F#">[<System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>Java.Interop.JniPeerMembers</ReturnType>
</ReturnValue>
<Docs>
<summary>To be added.</summary>
<value>To be added.</value>
<remarks>
<para>Portions of this page are modifications based on work created and shared by the <format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format> and used according to terms described in the <format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
</Docs>
</Member>
<Member MemberName="OnBind">
<MemberSignature Language="C#" Value="public override sealed Android.OS.IBinder? OnBind (Android.Content.Intent? intent);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance class Android.OS.IBinder OnBind(class Android.Content.Intent intent) cil managed" />
<MemberSignature Language="DocId" Value="M:Android.Service.Autofill.AutofillService.OnBind(Android.Content.Intent)" />
<MemberSignature Language="F#" Value="override this.OnBind : Android.Content.Intent -> Android.OS.IBinder" Usage="autofillService.OnBind intent" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.Register("onBind", "(Landroid/content/Intent;)Landroid/os/IBinder;", "", ApiSince=26)]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.Register("onBind", "(Landroid/content/Intent;)Landroid/os/IBinder;", "", ApiSince=26)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Runtime.Versioning.SupportedOSPlatform("android26.0")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.SupportedOSPlatform("android26.0")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>Android.OS.IBinder</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="intent" Type="Android.Content.Intent" />
</Parameters>
<Docs>
<param name="intent">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>
<para>Portions of this page are modifications based on work created and shared by the <format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format> and used according to terms described in the <format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
</Docs>
</Member>
<Member MemberName="OnConnected">
<MemberSignature Language="C#" Value="public virtual void OnConnected ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void OnConnected() cil managed" />
<MemberSignature Language="DocId" Value="M:Android.Service.Autofill.AutofillService.OnConnected" />
<MemberSignature Language="F#" Value="abstract member OnConnected : unit -> unit
override this.OnConnected : unit -> unit" Usage="autofillService.OnConnected " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.Register("onConnected", "()V", "GetOnConnectedHandler", ApiSince=26)]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.Register("onConnected", "()V", "GetOnConnectedHandler", ApiSince=26)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Runtime.Versioning.SupportedOSPlatform("android26.0")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.SupportedOSPlatform("android26.0")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Called when the Android system connects to service.</summary>
<remarks>
<para>Called when the Android system connects to service.</para>
<para>You should generally do initialization here rather than in <c>#onCreate</c>.</para>
<para>
<format type="text/html">
<a href="https://developer.android.com/reference/android/service/autofill/AutofillService#onConnected()" title="Reference documentation">Java documentation for <code>android.service.autofill.AutofillService.onConnected()</code>.</a>
</format>
</para>
<para>
Portions of this page are modifications based on work created and shared by the
<format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format>
and used according to terms described in the
<format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
</Docs>
</Member>
<Member MemberName="OnDisconnected">
<MemberSignature Language="C#" Value="public virtual void OnDisconnected ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void OnDisconnected() cil managed" />
<MemberSignature Language="DocId" Value="M:Android.Service.Autofill.AutofillService.OnDisconnected" />
<MemberSignature Language="F#" Value="abstract member OnDisconnected : unit -> unit
override this.OnDisconnected : unit -> unit" Usage="autofillService.OnDisconnected " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.Register("onDisconnected", "()V", "GetOnDisconnectedHandler", ApiSince=26)]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.Register("onDisconnected", "()V", "GetOnDisconnectedHandler", ApiSince=26)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Runtime.Versioning.SupportedOSPlatform("android26.0")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.SupportedOSPlatform("android26.0")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Called when the Android system disconnects from the service.</summary>
<remarks>
<para>Called when the Android system disconnects from the service.</para>
<para>At this point this service may no longer be an active <c>AutofillService</c>.
It should not make calls on <c>AutofillManager</c> that requires the caller to be
the current service.</para>
<para>
<format type="text/html">
<a href="https://developer.android.com/reference/android/service/autofill/AutofillService#onDisconnected()" title="Reference documentation">Java documentation for <code>android.service.autofill.AutofillService.onDisconnected()</code>.</a>
</format>
</para>
<para>
Portions of this page are modifications based on work created and shared by the
<format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format>
and used according to terms described in the
<format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
</Docs>
</Member>
<Member MemberName="OnFillRequest">
<MemberSignature Language="C#" Value="public abstract void OnFillRequest (Android.Service.Autofill.FillRequest request, Android.OS.CancellationSignal cancellationSignal, Android.Service.Autofill.FillCallback callback);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void OnFillRequest(class Android.Service.Autofill.FillRequest request, class Android.OS.CancellationSignal cancellationSignal, class Android.Service.Autofill.FillCallback callback) cil managed" />
<MemberSignature Language="DocId" Value="M:Android.Service.Autofill.AutofillService.OnFillRequest(Android.Service.Autofill.FillRequest,Android.OS.CancellationSignal,Android.Service.Autofill.FillCallback)" />
<MemberSignature Language="F#" Value="abstract member OnFillRequest : Android.Service.Autofill.FillRequest * Android.OS.CancellationSignal * Android.Service.Autofill.FillCallback -> unit" Usage="autofillService.OnFillRequest (request, cancellationSignal, callback)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.Register("onFillRequest", "(Landroid/service/autofill/FillRequest;Landroid/os/CancellationSignal;Landroid/service/autofill/FillCallback;)V", "GetOnFillRequest_Landroid_service_autofill_FillRequest_Landroid_os_CancellationSignal_Landroid_service_autofill_FillCallback_Handler", ApiSince=26)]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.Register("onFillRequest", "(Landroid/service/autofill/FillRequest;Landroid/os/CancellationSignal;Landroid/service/autofill/FillCallback;)V", "GetOnFillRequest_Landroid_service_autofill_FillRequest_Landroid_os_CancellationSignal_Landroid_service_autofill_FillCallback_Handler", ApiSince=26)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Runtime.Versioning.SupportedOSPlatform("android26.0")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.SupportedOSPlatform("android26.0")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="request" Type="Android.Service.Autofill.FillRequest" />
<Parameter Name="cancellationSignal" Type="Android.OS.CancellationSignal" />
<Parameter Name="callback" Type="Android.Service.Autofill.FillCallback" />
</Parameters>
<Docs>
<param name="request">the <c>FillRequest request</c> to handle.
See <c>FillResponse</c> for examples of multiple-sections requests.</param>
<param name="cancellationSignal">signal for observing cancellation requests. The system will use
this to notify you that the fill result is no longer needed and you should stop
handling this fill request in order to save resources.</param>
<param name="callback">object used to notify the result of the request.</param>
<summary>Called by the Android system do decide if a screen can be autofilled by the service.</summary>
<remarks>
<para>Called by the Android system do decide if a screen can be autofilled by the service.</para>
<para>Service must call one of the <c>FillCallback</c> methods (like
<c>FillCallback#onSuccess(FillResponse)</c>
or <c>FillCallback#onFailure(CharSequence)</c>)
to notify the result of the request.</para>
<para>
<format type="text/html">
<a href="https://developer.android.com/reference/android/service/autofill/AutofillService#onFillRequest(android.service.autofill.FillRequest,%20android.os.CancellationSignal,%20android.service.autofill.FillCallback)" title="Reference documentation">Java documentation for <code>android.service.autofill.AutofillService.onFillRequest(android.service.autofill.FillRequest, android.os.CancellationSignal, android.service.autofill.FillCallback)</code>.</a>
</format>
</para>
<para>
Portions of this page are modifications based on work created and shared by the
<format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format>
and used according to terms described in the
<format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
</Docs>
</Member>
<Member MemberName="OnSavedDatasetsInfoRequest">
<MemberSignature Language="C#" Value="public virtual void OnSavedDatasetsInfoRequest (Android.Service.Autofill.ISavedDatasetsInfoCallback callback);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void OnSavedDatasetsInfoRequest(class Android.Service.Autofill.ISavedDatasetsInfoCallback callback) cil managed" />
<MemberSignature Language="DocId" Value="M:Android.Service.Autofill.AutofillService.OnSavedDatasetsInfoRequest(Android.Service.Autofill.ISavedDatasetsInfoCallback)" />
<MemberSignature Language="F#" Value="abstract member OnSavedDatasetsInfoRequest : Android.Service.Autofill.ISavedDatasetsInfoCallback -> unit
override this.OnSavedDatasetsInfoRequest : Android.Service.Autofill.ISavedDatasetsInfoCallback -> unit" Usage="autofillService.OnSavedDatasetsInfoRequest callback" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.Register("onSavedDatasetsInfoRequest", "(Landroid/service/autofill/SavedDatasetsInfoCallback;)V", "GetOnSavedDatasetsInfoRequest_Landroid_service_autofill_SavedDatasetsInfoCallback_Handler", ApiSince=31)]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.Register("onSavedDatasetsInfoRequest", "(Landroid/service/autofill/SavedDatasetsInfoCallback;)V", "GetOnSavedDatasetsInfoRequest_Landroid_service_autofill_SavedDatasetsInfoCallback_Handler", ApiSince=31)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Runtime.Versioning.SupportedOSPlatform("android31.0")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.SupportedOSPlatform("android31.0")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="callback" Type="Android.Service.Autofill.ISavedDatasetsInfoCallback" />
</Parameters>
<Docs>
<param name="callback">callback for responding to the request</param>
<summary>Called from system settings to display information about the datasets the user saved to this
service.</summary>
<remarks>
<para>Called from system settings to display information about the datasets the user saved to this
service.</para>
<para>There is no timeout for the request, but it's recommended to return the result within a
few seconds, or the user may navigate away from the activity that would display the result.</para>
<para>
<format type="text/html">
<a href="https://developer.android.com/reference/android/service/autofill/AutofillService#onSavedDatasetsInfoRequest(android.service.autofill.SavedDatasetsInfoCallback)" title="Reference documentation">Java documentation for <code>android.service.autofill.AutofillService.onSavedDatasetsInfoRequest(android.service.autofill.SavedDatasetsInfoCallback)</code>.</a>
</format>
</para>
<para>
Portions of this page are modifications based on work created and shared by the
<format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format>
and used according to terms described in the
<format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
</Docs>
</Member>
<Member MemberName="OnSaveRequest">
<MemberSignature Language="C#" Value="public abstract void OnSaveRequest (Android.Service.Autofill.SaveRequest request, Android.Service.Autofill.SaveCallback callback);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void OnSaveRequest(class Android.Service.Autofill.SaveRequest request, class Android.Service.Autofill.SaveCallback callback) cil managed" />
<MemberSignature Language="DocId" Value="M:Android.Service.Autofill.AutofillService.OnSaveRequest(Android.Service.Autofill.SaveRequest,Android.Service.Autofill.SaveCallback)" />
<MemberSignature Language="F#" Value="abstract member OnSaveRequest : Android.Service.Autofill.SaveRequest * Android.Service.Autofill.SaveCallback -> unit" Usage="autofillService.OnSaveRequest (request, callback)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.Register("onSaveRequest", "(Landroid/service/autofill/SaveRequest;Landroid/service/autofill/SaveCallback;)V", "GetOnSaveRequest_Landroid_service_autofill_SaveRequest_Landroid_service_autofill_SaveCallback_Handler", ApiSince=26)]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.Register("onSaveRequest", "(Landroid/service/autofill/SaveRequest;Landroid/service/autofill/SaveCallback;)V", "GetOnSaveRequest_Landroid_service_autofill_SaveRequest_Landroid_service_autofill_SaveCallback_Handler", ApiSince=26)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Runtime.Versioning.SupportedOSPlatform("android26.0")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.SupportedOSPlatform("android26.0")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="request" Type="Android.Service.Autofill.SaveRequest" />
<Parameter Name="callback" Type="Android.Service.Autofill.SaveCallback" />
</Parameters>
<Docs>
<param name="request">the <c>SaveRequest request</c> to handle.
See <c>FillResponse</c> for examples of multiple-sections requests.</param>
<param name="callback">object used to notify the result of the request.</param>
<summary>Called when the user requests the service to save the contents of a screen.</summary>
<remarks>
<para>Called when the user requests the service to save the contents of a screen.</para>
<para>If the service could not handle the request right away&mdash;for example, because it must
launch an activity asking the user to authenticate first or because the network is
down&mdash;the service could keep the <c>SaveRequest request</c> and reuse it later,
but the service <b>must always</b> call <c>SaveCallback#onSuccess()</c> or
<c>SaveCallback#onSuccess(android.content.IntentSender)</c> right away.</para>
<para><b>Note:</b> To retrieve the actual value of fields input by the user, the service
should call
<c>android.app.assist.AssistStructure.ViewNode#getAutofillValue()</c>; if it calls
<c>android.app.assist.AssistStructure.ViewNode#getText()</c> or other methods, there is no
guarantee such method will return the most recent value of the field.</para>
<para>
<format type="text/html">
<a href="https://developer.android.com/reference/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)" title="Reference documentation">Java documentation for <code>android.service.autofill.AutofillService.onSaveRequest(android.service.autofill.SaveRequest, android.service.autofill.SaveCallback)</code>.</a>
</format>
</para>
<para>
Portions of this page are modifications based on work created and shared by the
<format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format>
and used according to terms described in the
<format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
</Docs>
</Member>
<Member MemberName="ServiceInterface">
<MemberSignature Language="C#" Value="public const string ServiceInterface;" />
<MemberSignature Language="ILAsm" Value=".field public static literal string ServiceInterface" />
<MemberSignature Language="DocId" Value="F:Android.Service.Autofill.AutofillService.ServiceInterface" />
<MemberSignature Language="F#" Value="val mutable ServiceInterface : string" Usage="Android.Service.Autofill.AutofillService.ServiceInterface" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.Register("SERVICE_INTERFACE", ApiSince=26)]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.Register("SERVICE_INTERFACE", ApiSince=26)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Runtime.Versioning.SupportedOSPlatform("android26.0")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.SupportedOSPlatform("android26.0")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>The <c>Intent</c> that must be declared as handled by the service.</summary>
<remarks>
<para>The <c>Intent</c> that must be declared as handled by the service.
To be supported, the service must also require the
<c>android.Manifest.permission#BIND_AUTOFILL_SERVICE</c> permission so
that other applications can not abuse it.</para>
<para>
<format type="text/html">
<a href="https://developer.android.com/reference/android/service/autofill/AutofillService#SERVICE_INTERFACE" title="Reference documentation">Java documentation for <code>android.service.autofill.AutofillService.SERVICE_INTERFACE</code>.</a>
</format>
</para>
<para>
Portions of this page are modifications based on work created and shared by the
<format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format>
and used according to terms described in the
<format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
</Docs>
</Member>
<Member MemberName="ServiceMetaData">
<MemberSignature Language="C#" Value="public const string ServiceMetaData;" />
<MemberSignature Language="ILAsm" Value=".field public static literal string ServiceMetaData" />
<MemberSignature Language="DocId" Value="F:Android.Service.Autofill.AutofillService.ServiceMetaData" />
<MemberSignature Language="F#" Value="val mutable ServiceMetaData : string" Usage="Android.Service.Autofill.AutofillService.ServiceMetaData" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.Register("SERVICE_META_DATA", ApiSince=26)]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.Register("SERVICE_META_DATA", ApiSince=26)>]</AttributeName>
</Attribute>