Commit Graph

942 Commits

Author SHA1 Message Date
TYM Tsai
d66c967c71 Implement inline suggestion tooltip
In the InlineSuggestionFactory, it will filter the tooltips by the
field let only the first one can pass to the IME and drop others.
When the IME inflates the inline suggestion, if there is a tooltip of
the suggestion view, inflates the tooltip view at the same time. It
will create the InlineTooltipUi that will be a popup window and
contains the surface view of the tooltip.

Bug: 172024354
Test: atest CtsAutoFillServiceTestCases:InlineTooltipTest
Change-Id: I6f20dcad6d03432017e684964eca52dff2609205
2021-03-18 09:30:45 +08:00
TreeHugger Robot
14ff834581 Merge changes from topic "client_suggestions_fillrequest-sc-dev" into sc-dev
* changes:
  Implements Autofill fill request to support client suggestions
  Adds fill request APIs for the client suggestions
2021-03-09 04:55:55 +00:00
TYM Tsai
60fa57ee2a Implements Autofill fill request to support client suggestions
Bug: 172024354
Test: atest CtsAutoFillServiceTestCases
Change-Id: I28a00cb76260bed0c311e7b845d93f3fc71c4447
2021-03-08 15:38:40 +08:00
TreeHugger Robot
10c0b8a7ae Merge "Pass InlineSuggestionsRequest via autofill auth intent extras" into sc-dev 2021-03-06 18:46:41 +00:00
Feng Cao
235ee12b14 Pass InlineSuggestionsRequest via autofill auth intent extras
Bug: 159616829
Test: atest android.autofillservice.cts.inline.InlineAuthenticationTest

Change-Id: Ifb4b60afe2c241011138d1c5fa8195585d53b82b
2021-02-26 15:22:29 -08:00
Stevie Kideckel
289da0b787 Add checked change APIs to RemoteViews
Bug: 179245670
Test: built sample app to use APIs with and without collections, atest
Change-Id: I5474bfb7dc15d559867063d1d8516b8ca2ef9755
2021-02-17 12:01:28 +00:00
Feng Cao
b965fb4835 Allow autofill auth intent result to specify whether the new dataset is ephemeral or not
Test: atest android.autofillservice.cts.inline.InlineAuthenticationTest
Test: atest android.autofillservice.cts.inline
Bug: 175152049

Change-Id: I1f8ee3999e5d5070a0453a4af3aa45b46aeef92d
2021-02-04 15:42:24 -08:00
Nikita Dubrovsky
981cde188f When autofilling content, grant URI permissions to the target app
Bug: 168341541
Test: atest CtsAutoFillServiceTestCases:DatasetTest
Test: Manually tested image suggestions when the target app doesn't have media store permissions
Change-Id: I42546c76e45ec404e8d8de3bf63ca094d8a494c6
2020-12-28 17:27:48 -08:00
Ahaan Ugale
2e16bf666c Merge "Revert "Unify and clarify divergent flows e.g. where augmented autofill or"" 2020-12-16 20:00:40 +00:00
Ahaan Ugale
3c2cb70013 Revert "Unify and clarify divergent flows e.g. where augmented autofill or"
This reverts commit 6e95425270.

Reason for revert: breaks InlineAugmentedLoginActivityTest
Fix: 175675905

Change-Id: If57386e8cfb18eda1223f9ae3ce28e918327749a
2020-12-16 17:07:46 +00:00
Adam He
165fe1918b Merge "Unify and clarify divergent flows e.g. where augmented autofill or inline autofill is triggered." 2020-12-14 22:28:32 +00:00
David James
61ef6329a3 Move CtsAutoFillServiceTestCases to group presubmit-large
The test config takes longer than 15mins to run. Move it to a dedicated
group for running slow presubmit Test Mapping tests.

Bug: 174654670
Bug: 174495337
Bug: 175150979

Change-Id: I533e749f57798c4b162a105246b51854a539a65f
Test: None
2020-12-11 17:29:24 +00:00
Adam He
6e95425270 Unify and clarify divergent flows e.g. where augmented autofill or
inline autofill is triggered.

Bug: 171351158
Test: atest CtsAutoFillServiceTestCases
Change-Id: Ifc5db4f6c59ffa1cc7b55e1a61c956e758d15ebc
2020-12-08 12:09:10 -08:00
Riddle Hsu
f90b2d4610 Move launched activity info getter to ActivityClientController
- Add getLaunchedFromUid and getLaunchedFromPackage into Activity
  because they are used in several places.
- Move getActivityClassForToken to ActivityTaskManagerInternal#
  getActivityName because it is only used in system server.
- Remove getPackageForToken because it is no longer used.

Bug: 174041144
Bug: 174040691
Test: CtsWindowManagerDeviceTestCases

Change-Id: Iac1581ac2271baf1ab1625ced6cc1f42bf05eaf5
2020-12-08 13:10:10 +08:00
Adam He
b32f5f70c4 Merge "Add lifecycle states to Session to help add clarity and ease of maintenance to Sessions." 2020-12-03 21:53:57 +00:00
Adam He
5ccbeec555 Add lifecycle states to Session to help add clarity and ease of
maintenance to Sessions.

* mSessionState is the unique lifecycle State of the current Session.

* mSessionInfo contains metadata and other state identifying booleans
for the current Session.

Bug: 171350451
Bug: 162357598
Test: atest CtsAutoFillServiceTestCases
Change-Id: Id8cead9e5299b3f4e24c035706e04fa46555fc9b
2020-11-30 13:28:49 -08:00
Joanne Chung
b6a336826a Add needed tests in TEST_MAPPINGs under autofill related paths
Add basic tests into TEST_MAPPING to make sure the tests can be
tested in presubmit. There is a 30 minutes limitation for presubmit
which doesn't allow to run all autofill tests. We only choose some
tests and add @Presubmit annotation to the tests that want to verify
in presubmit.

The tests contains basic fillUi, saveUi, authentication, filtering,
fill history, virtual view, compat mode. Skip webview because it is
a high flaky fail tests. The presubmit time is 20-30 minutes for now,
we can add/delete the chosen tests in presubmit when we receiving the
fails.

Bug: 154961272
Test: TreeHugger
Change-Id: I25684a2122c4e705b75b9a30c3b7a61337bbd1a7
2020-11-25 19:46:36 +08:00
Joanne Chung
5b5f1c0acb Use the flag FLAG_MUTABLE when creating the PendingIntent
Starting with S, any app targeting S+ will need to specify
explicitly either FLAG_MUTABLE or FLAG_IMMUTABLE when creating
PendingIntents.

This change helps mitigate against implicit PendingIntent reuse.
At present, all PendingIntents are mutable by default unless
FLAG_IMMUTABLE is explicitly set when creating them. This often
leads to developers accidentally making the PendingIntents mutable
and thus handing their receivers powers to fill in critical fields.

Because the autofill saveui retore mechanism will need to update it,
the PendingIntent should be mutable.

Bug: 170771150
Test: atest CtsAutoFillServiceTestCases
Test: Manual. Make sure the function works normal.
Test: Don't see PendingIntent error log.
Change-Id: I6e03a48968b98dec10e9c9dc05d1f3af42f8f0e5
2020-11-09 18:53:35 +08:00
Adam He
bb3ab9d100 Merge "Rename session ending method calls to use consistent names." 2020-11-03 21:25:38 +00:00
Adam He
49ca81b0ea Rename session ending method calls to use consistent names.
* Session contains removeFromService() and destroy().
removeFromService() removes the session and also calls destroy()
* AFManagerServiceImpl has renamed methods to remove*Sessions() since
it's actually calling into removeFromService instead of just destroy().

BYPASS_INCLUSIVE_LANGUAGE_REASON=will_do_in_separate_cl

Bug: 162357598
Test: atest CtsAutoFillServiceTestCases
Change-Id: I4ddc4b863b2f3c962408dc0e54f8be5b34ee32b4
2020-11-02 17:15:55 -08:00
Nikita Dubrovsky
00d2ce0b6f Use a separate code path for rich content in augmented autofill
Image suggestions (and other rich content) are not handled the same way
as primitive autofill values. These suggestions are also only applicable
to augmented autofill. Therefore, instead of reusing AutofillType and
AutofillValue, we use a separate code path to insert rich content. A
follow-on change will remove AUTOFILL_TYPE_RICH_CONTENT and the
corresponding code on AutofillValue.

Bug: 168837034
Test: Manual and unit tests
  atest CtsAutoFillServiceTestCases:DatasetTest
  atest CtsAutoFillServiceTestCases:InlineAugmentedAuthTest
  atest CtsAutoFillServiceTestCases:InlineAugmentedLoginActivityTest
Change-Id: I4fa3baf2b545908fc25f3a6e28a7addc7004786b
2020-10-27 16:16:06 -07:00
Adam He
b39ce19322 Merge "Remove CountDownLatch from AssistReceiver." 2020-10-20 20:36:55 +00:00
Adam He
25a55b6e1b Merge "Misc small changes in Session.java." 2020-10-20 20:36:00 +00:00
Adam He
5a9bf59f38 Remove CountDownLatch from AssistReceiver.
We track whether inline request is needed with a separate boolean. This
also resolve the bug where the CountDownLatch was accounting for both
inline and regular request, and errors when due to async on multiple
requests, receives multiple regular request instead.

Bug: 162357598
Fixes: 159417365
Test: atest CtsAutoFillServiceTestCases
Change-Id: I56e11163d9163f73f807f6adf06d93bf26617173
2020-10-19 15:49:52 -07:00
Adam He
b343cb4433 Misc small changes in Session.java.
* Move helper methods to static methods in Helper.java
* Add documentation on ambiguous methods.
* Rename method to end with *Locked for consistency.

Bug: 162357598
Test: atest CtsAutoFillServiceTestCases
Change-Id: I1b2f788a74fa16f566520f5e83c2df21ffbca2dc
2020-10-19 15:46:10 -07:00
TreeHugger Robot
855b94d7d7 Merge "Add the reason why a save dialog was not shown to FillEventHistory." 2020-10-16 03:21:16 +00:00
lpeter
5518d64780 Add the reason why a save dialog was not shown to FillEventHistory.
In order to provide a better user experience, it would better know the
reason why a save dialog was not shown and improve the autofill experience.
So it is necessary to add the reason why a save dialog was not shown to
FillEventHistory.

Bug: 158328375
Test: atest FillEventHistoryTest
Test: atest InlineFillEventHistoryTest
Change-Id: I50c1e40334066d3f4844426c4b03294079a967b2
2020-10-14 02:35:10 +08:00
Adam He
6be74a57ab Refactor and simplify InlineFillUi and InlineSuggestionFactory.
* Create InlineFillUiInfo to encapsulate the numberous arguments passed
into the factory.
* Combine CreateInlineSuggestions API for regular and augmented
autofill.

Bug: 162357598
Test: atest CtsAutoFillServiceTestCases
Change-Id: I64d5ca2aec510b9e04ebc3c499ca0029dc96925c
2020-09-17 16:00:18 -07:00
Jeff Sharkey
4b5b0174d0 Merge changes from topic "sep11" am: c0b288133a am: 69e6f07347 am: 741c0a78cc am: da7478b570 am: 487d394296
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1426195

Change-Id: Id01f468b43fd5b2aada78608010625b392c1b647
2020-09-15 21:01:48 +00:00
Jeff Sharkey
487d394296 Merge changes from topic "sep11" am: c0b288133a am: 69e6f07347 am: 741c0a78cc am: da7478b570
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1426195

Change-Id: I79488866c538bf9e76d0a6429e30262978f6fdab
2020-09-15 00:13:08 +00:00
Jeff Sharkey
4172f8a62c Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Test: none
Bug: 168334533
Exempt-From-Owner-Approval: docs updates
Change-Id: If75259aab72329f9f8b0e1972a96370ca5134e2c
2020-09-14 10:00:10 -06:00
Xin Li
628590d7ec Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27
Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2
2020-08-31 21:21:38 -07:00
Felipe Leme
7a907dbe46 Refactored user switch workflow to decouple UserInfo from TargetUser.
UserController calls SystemServiceManager on some stages of the user
switch lifecycle, and SystemServiceManager calls the respective
callbacks in the SystemService objects it manage.

Prior to Android 11, these callbacks would take a @UserIdInt userid,
but now they take a TargetUser (which in turns contains a Userinfo).
So, currently, UserController calls SystemServiceManager passing the
userid, and SystemServiceManager gets the UserInfo from
UserManagerService. That works fine most of the time, but there might
be some race conditions when a user is removed that can crash the
system when such user is stopped (because UserManagerService doesn't
have its UserInfo anymore).

This CL fixes this issue by refactoring the user switch workflow so:

- TargetUser doesn't hold a reference to the UserInfo anymore, but
  offer the methods needed by SystemService implementations.
- SystemServiceManager keeps track of the TargetUser objects used in
  the callbacks.

Test: manual verification

Fixes: 159831354

Change-Id: If68ab1b5e247c7389c8cac16432d8b8809507e86
2020-08-13 16:56:34 -07:00
TreeHugger Robot
7d77f1e7d2 Merge "Fix "null" toast when FillCallback.onFailure(null) called." into rvc-qpr-dev am: 906ec8897e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12279991

Change-Id: I63f90c2cd18af251b645e5484c29a07dbb81ee94
2020-08-12 08:38:35 +00:00
Adam He
6b712bb6de Fix SaveUi to properly resolve for instant apps.
This issue causes CTS test failures while running instant mode tests.
This patch will help partners pass instant mode CTS successfully.

Bug: 153099178
Test: atest --instant android.autofillservice.cts.SimpleSaveActivityTest
Change-Id: I2bd6c553c75a1a207d7bfd7113aad5e377880b3e
2020-08-10 22:22:56 +00:00
Felipe Leme
46a0354076 Merge "Removed @Deprecated SystemService callback methods that take a userId." 2020-08-03 15:23:25 +00:00
Felipe Leme
837f8c1e8a Removed @Deprecated SystemService callback methods that take a userId.
This is just a plain refactoring: the removed methods in the changed
classes were called by default by the new methods in the superclass
(SystemService).

Test: m
Test: atest NotificationManagerServiceTest BackupManagerServiceRoboTest

Fixes: 161943081

Exempt-From-Owner-Approval: refactoring without side-effects

Change-Id: Ifd8df592eb4494cc0922b7e0b2ff20187b8a8b3e
2020-08-03 07:24:26 +00:00
Joanne Chung
fe89715c86 Fix "null" toast when FillCallback.onFailure(null) called.
Root cause
The error message is set by AutofillService, AutofillService calls
FillCallback.onFailure(null) back to the platform. Because a081250
uses String.valueOf(message), this method will make a null object
become to a "null" string. This may cause the Autofill session to
think we should show message because of a non-null message. And if
the AutofillService target SDK is lower than 29, we don't ignore show
message, then users will see a "null" toast.

Solution
Instead of passing the message parameter to String.valueOf() directly
, we check the message first, only passing to String.valueOf() if the
message is not null. And we pass an empty string if the message
parameter is null.

Bug: 159888723
Test: Use a test AutofillService which target SDK is lower than 29,
make sure no null toast is shown
Test: atest CtsAutoFillServiceTestCases

Change-Id: Id7ff581b3a7f35cf97b4f3405a40bfa1a420823e
(cherry picked from commit 3c7ac7de46)
2020-07-31 08:23:08 +00:00
Treehugger Robot
7c903239a1 Merge "Update language to comply with Android's inclusive language guidance" am: 2f9678b015 am: ba422d29e0 am: ff7f3b8bfe am: 505fcf9d0f am: 353c4b1178
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1375857

Change-Id: I0130ef7ce116e6166ec36748762b9907265eff65
2020-07-31 01:03:32 +00:00
Treehugger Robot
ff7f3b8bfe Merge "Update language to comply with Android's inclusive language guidance" am: 2f9678b015 am: ba422d29e0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1375857

Change-Id: I38145552ef5364e488946e4cf71d70beaf25217f
2020-07-30 02:01:49 +00:00
Joanne Chung
3c7ac7de46 Fix "null" toast when FillCallback.onFailure(null) called.
Root cause
The error message is set by AutofillService, AutofillService calls
FillCallback.onFailure(null) back to the platform. Because a081250
uses String.valueOf(message), this method will make a null object
become to a "null" string. This may cause the Autofill session to
think we should show message because of a non-null message. And if
the AutofillService target SDK is lower than 29, we don't ignore show
message, then users will see a "null" toast.

Solution
Instead of passing the message parameter to String.valueOf() directly
, we check the message first, only passing to String.valueOf() if the
message is not null. And we pass an empty string if the message
parameter is null.

Bug: 159888723
Test: Use a test AutofillService which target SDK is lower than 29,
make sure no null toast is shown
Test: atest CtsAutoFillServiceTestCases:LoginActivityTest#\
testAutofillAgainAfterOnFailure

Change-Id: Id7ff581b3a7f35cf97b4f3405a40bfa1a420823e
2020-07-29 17:36:10 +08:00
Saint Chou
f4702f4b67 Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

#inclusivefixit

Bug: 161896447
Test: NA (Comment only)

Change-Id: I4d45df17a30ce09e99eec4e18ac1a94de5d6b698
2020-07-29 09:08:21 +00:00
Adam He
38fdfe471a Updated docs for Autofill inline Session/controller.
Fixes: 160730285
Test: atest android.autofillservice.cts.inline
Change-Id: I83b5002f306c369999e1a131d5fda6ea5619e1dc
2020-07-13 16:11:46 -07:00
lpeter
a383f339de Change to drop down when the inline suggestions don't be shown in IME.
The current implementation has a problem where:
In the autofill side, there can be multiple autofill sessions existed
at the same time. But in the IME side, there is always only one
InlineSuggestionSession at any given time. It will cause the previous
autofill session to fail communication with IME.

It would better change to drop down UI when the autofill inline
suggestions don't be shown in IME.

How to reproduce this issue:
To add an input field with autofillable into the authentication activity
of InlineFillService. To tap on the input field of the authentication
activity during the authentication flow. After completing the
authentication, the inline suggestions won't be shown in IME.

BTW, if the input field is marked as non-autofillable, this issue won't
occur.

Manual verification:
1.Tested this patch with InlineFillService and it worked well.
2.Feng also helped to test this patch with the webview
(sort of randomly), and didn't find any broken case

Bug: 158877106
Test: atest CtsInputMethodTestCases
Test: atest CtsAutoFillServiceTestCases
Test: new CTS test Ie1d9055b0eabfcaa00861869467be8dcee25833e
Test: manual verification with InlineFillService
Test: Feng also helped to test this patch with the webview
Change-Id: Ib06edd823fa4478f34362164f3f7dd3544e51705
2020-07-08 17:40:00 +00:00
Feng Cao
32cfac9ed7 Do not replace the authenticated dataset for pinned inline suggestion
* For the case where the pinned inline suggestion triggers an
  pending intent through the auth flow, and it returns a dataset
  to be autofilled, previously we would replace the existing
  dataset with the returned dataset. However, this is causing
  several potential issues:
  1. if the returned dataset doesn't contain inline presentation
     the the pinned icon will not show again
  2. if the returned dataset contains inline presentation but not
     the pending intent, then the pinned icon will show up again
     but tapping on it will not launch the pending intent
  3. if the returned dataset contains the inline presentaion and
     the pending intent, then when we "autofill" it, it'll fire
     the pending intent directly as opposed to filling in the
     value
* We fix the issue by not replacing the old dataset if the dataset
  is a pinned inline suggestion.
* One caveat of the approach is that: a dataset can potentially
  have multiple fields, and it's possible that some of the fields'
  has inline presentation and some don't. It's also possible that
  some of the fields' inline presentation is pinned and some isn't.
  So the concept of whether a Dataset is pinned or not is
  ill-defined. Here we say a dataset is pinned if any of the field
  has a pinned inline presentation in the dataset. It's not ideal
  but hopefully it is sufficient for most of the cases.
* An alternative approach is to have the autofill provider telling
  whether they want to replace the old dataset or not, through
  a new field in the returned Bundle. But that requres an API change
  so is infeasible at this time.

Test: atest android.autofillservice.cts.inline
Test: atest android.autofillservice.cts.augmented
Test: atest android.autofillservice.cts.LoginActivityTest
Test: atest android.autofillservice.cts.AuthenticationTest
Bug: 159367101

Change-Id: I6d162aeb88a4655989c1aa315df8304c0980ac60
2020-06-25 17:39:13 -07:00
TreeHugger Robot
6e3a4d7625 Merge "Release remove inline suggestion views when session destroyed" into rvc-dev 2020-06-24 05:31:34 +00:00
Feng Cao
17ca1ee84e Release remove inline suggestion views when session destroyed
* Attach to each inline suggestion remote view the user id
  and session id, which together identify a session. Then when
  the session is destroyed, we release all the remote views
  associated with the it.
* Worst scenario is that the IME is still showing the UI when
  the remote view is released due to session destroy, in which
  case the suggestion will disappear from the IME window. But
  we also make sure we send an empty response to IME before
  releasing the views, so it should be bad. Plus when a session
  is destroyed, interacting with the suggestion UI doesn't do
  anything, so it's not very helpful to show them.
* Also add a dump method to the InlineSuggestionRenderService
  to help with debugging

Test: atest android.autofillservice.cts.inline
Bug: 154683107

Change-Id: I488fd9d9af08d0df3ffd3c851f96c567d07eed5a
2020-06-23 19:17:42 -07:00
Adam He
b58c5100ee Merge "Add missing cases where empty suggestions should be sent to IME." into rvc-dev 2020-06-22 20:35:14 +00:00
Adam He
2359a78aaa Merge "Add call to send empty suggestions to IME on cancelling augmented autofill." into rvc-dev 2020-06-22 20:34:55 +00:00
Adam He
c71f42e751 Add call to send empty suggestions to IME on cancelling augmented
autofill.

Bug: 159472108
Test: atest InlineLoginActivityTest
Change-Id: Ie3bebffbee32dbfc11c931096a39641a4815293e
2020-06-22 11:22:45 -07:00