224 Commits

Author SHA1 Message Date
Felipe Leme
2f0d132471 Autofill fixes for secondary users:
- Display the SaveUI on all users.
- Dismiss the UI when switching users.
- Fix security check on disableOwnedAutofillServicesLocked()

Test: manual verification
Change-Id: I4e9167314f1feeda618db6c57735cc31d84486c1
Fixes: 62828906
2017-06-21 17:50:51 -07:00
Felipe Leme
d013bcea97 Don't add FillEventHistory events to the wrong session.
The AutofillSession.getFillEventHistory() method returns only the event history
for the last onFillRequest(). In the scenario where the user switches
activities and the server has multiple sessions open, only the events for the
last session should be recorded.

Test: existing CtsAutoFillServiceTestCases pass
Test: LoginActivityTest.checkFillSelectionFromPreviousSessionIsDiscarded

Fixes: 62802026

Change-Id: I447ed77c2167095867b35d616b5cf2ae43aa28db
2017-06-20 17:31:20 -07:00
Felipe Leme
2e30c6f371 Fixed how FillEventHistory is reset and clarified javadoc.
Test: existing CtsAutoFillServiceTestCases pass
Test: checkFillSelectionIsResetAfterReturningNull()
Test: checkFillSelectionIsResetAfterReturningError()
Test: checkFillSelectionIsResetAfterTimeout()

Bug: 62802026

Change-Id: I389d95fc13c08f1056960e5f67e131c8dc306401
2017-06-20 14:54:05 -07:00
Felipe Leme
94b56207a4 Use an optimized findViewNodeByAutofillId(id) to get just one node.
Session was using findViewNodesByAutofillIds(ids) before, which not only was
not optimal, but error prone (for example, it could return a non-empty array
with an empty value).

Test: CtsAutoFillServiceTestCases pass
Fixes: 62532979

Change-Id: If984f1263cc3f2aac1d1e098687fe02d73c55211
2017-06-16 11:51:49 -07:00
Svetoslav Ganov
0541862ec5 Merge "Protect autofill UI against redressing" into oc-dev 2017-06-09 20:53:40 +00:00
Svetoslav Ganov
2ee821b675 Protect autofill UI against redressing
Test: LoginActivityTest#testAutoFillOneDatasetAndSaveHidingOverlays

bug:62357517

Change-Id: Idcac67e1013178ba6c0d83994d49f8b485b2d334
2017-06-08 17:22:49 -07:00
Felipe Leme
5f97880714 Closes Autofill UIs when back button is pressed.
Test: existing CtsAutoFillServiceTestCases pass
Test: LoginActivityTest#testSaveGoesAwayWhenTappingBackButton pass

Fixes: 62272098

Change-Id: Id34767ca32836f040e04790f0f2935ae49d88d71
2017-06-08 13:10:32 -07:00
Felipe Leme
72f2d98c5a Merge "Fixed autofill filter comparison." into oc-dev 2017-06-07 00:30:53 +00:00
Felipe Leme
be4420cf13 Merge "Improved debug to diagnose Save issues." into oc-dev 2017-06-07 00:26:12 +00:00
Felipe Leme
2e723982d5 Merge "Use initial value on save when value didn't change." into oc-dev 2017-06-07 00:25:11 +00:00
Felipe Leme
b372c74e88 Fixed autofill filter comparison.
Test: existing CtsAutoFillServiceTestCases pass
Test: filterTextDifferentPrefixes() pass

Fixes: 62377334

Change-Id: I9edaf500adad7e5775994a838410c3f8f6af2b1a
2017-06-06 13:52:22 -07:00
Felipe Leme
e8f6808079 Use initial value on save when value didn't change.
Otherwise, it will fail to call onSaveRequest() in scenarios where the service
required a field that was pre-populated for the app. For example, when the
service requires both a username and password, the app pre-populates the
username, and the user fills the password.

Test: new LoginActivityTest.testSaveOnlyTwoRequiredFieldsOnePrefilled() pass
Test: existing CtsAutoFillServiceTestCases pass

Bug: 62270740

Change-Id: Idbb11a8c2dab6741c18549c55dfdb71b483c2447
2017-06-06 13:49:42 -07:00
Felipe Leme
a844927cb6 Improved debug to diagnose Save issues.
Test: manual verification
Bug: 62272098

Change-Id: Id7a6765fbe4228fcabb6cc0df37c5fde102d7077
2017-06-06 08:58:46 -07:00
Felipe Leme
876377d0b2 Catch WindowManager exceptions so they don't crash the system.
WindowManager throws an IllegalStateException when adding a view twice; this
should never happen (since show() and hide() are always called in the UIThread),
but when it does, it should not crash the system.

Test: existing CtsAutoFillServiceTestCases pass
Fixes: 62262781

Change-Id: Idfd246ff173f4abb606865b7ba8cc367eb6acaad
2017-06-02 14:48:43 -07:00
TreeHugger Robot
d8d9758363 Merge "Don't automatically autofill when manual request returned just 1 dataset." into oc-dev 2017-05-31 20:43:20 +00:00
Felipe Leme
9b36dfb2b1 Don't call remoteFillService.destroy() until session is removed.
Test: CtsAutoFillServiceTestCases pass

Fixes: 62200831
Bug: 62106708

Change-Id: I4e54e28a347e800c0b8353938399c860f213edfa
2017-05-30 19:55:59 -07:00
Felipe Leme
8697a31d3c Don't automatically autofill when manual request returned just 1 dataset.
When the user manually requested autofill and the service returned just 1
dataset, the app was automatically filled with it.

The motivation here was that since the user explicitly asked for autofill,
it'd ok - and better for the user - to release the data to the app without
the selecting a dataset.

This assumption was ok initially, but now the API to manually request autofill
is public, so a malicious app could use to get autofill data without user
interation.

Test: CtsAutoFillServiceTestCases pass
Fixes: 62164695

Change-Id: I47c3d8c557533526572aa67a4240c0a57f54268d
2017-05-30 14:34:27 -07:00
Felipe Leme
350b2dca6c Disable autofill while user setup is not completed.
Test: manual verification with experimental app
Test: manual verification with Autofill with Google on flashed deviced
Test: existing CtsAutoFillServiceTestCases pass
Test: new LoginActivityTest.testSetupComplete pass

Fixes: 62049772

Change-Id: I1e914c44062755f8c88656482338e76aeaafd543
2017-05-26 11:16:04 -07:00
Felipe Leme
c368c0b5ab Merge "Autofill UI should still show when dataset authentication is cancelled." into oc-dev 2017-05-25 14:32:11 +00:00
Felipe Leme
0171840ceb Autofill UI should still show when dataset authentication is cancelled.
Test: manual verification
Test: existing CtsAutoFillServiceTestCases pass
Test: LoginActivityTest.testDatasetAuthTwoFieldsUserCancelsFirstAttempt

Fixes: 38427468

Change-Id: If8785ad8fda1408a5dee66c53f7dcb4c85d78262
2017-05-24 16:52:24 -07:00
Felipe Leme
0430207aeb Don't WTF when assist structure is missing.
That could happen when app throws an exception while filling it.

Fixes: 38312929
Test: manual verification by forcing an app to throw an exception

Change-Id: I7e94e9d352c4c3fd8adf01bcf7b25f66535e070d
2017-05-24 10:49:56 -07:00
Felipe Leme
27e202208b Hide Autofill UI when non-savable id is gone.
AutofillManager keeps track of which views the AutofillServiec is interested to
save, so when these views are gone, the session is finished.

But when the AutofillService returns a dataset whose views it can not save,
the FillUi for these views are not hiding when the views are gone. This CL
fixes this issue by:

- Keeping track which non-savable views should be tracked.
- Pass the view (instead of it's id) when the UI on such views should be hid.

This CL also optimized some AIDL and internal calls by avoiding the creating of
unnecessary Lists.

Test: manual verification with Snapchat
Test: existing CtsAutoFillServiceTestCases pass
Test: new tests on MultipleFragmentLoginTest pass

Fixes: 38199452
Change-Id: I78fa357962dbc6667146d8e08cd6bacb63e0f337
2017-05-23 10:46:24 -07:00
TreeHugger Robot
54ddf4a4e2 Merge "Fixed and improved (for reuse) PendingRequest lifecycle." into oc-dev 2017-05-14 20:50:46 +00:00
Felipe Leme
7f33cd350b Start a new session on manual request after session is "gone".
When the autofill service returns a null FillResponse, the session is marked
"gone" because the service cannot autofill it. But there might be cases where
the view structure change and it's now autofillable, so need to allow users
to manually request autofill again in such cases.

Fixes: 38205945
Test: CtsAutoFillServiceTestCases pass
Test: LoginActivityTest.testAutofillManuallyAfterServiceReturnedNoDatasets()
Test: LoginActivityTest.testAutofillManuallyAndSaveAfterServiceReturnedNoDatasets()

Change-Id: I9b23c255e563dd0646bf266d31ddb10dcc4f7f6d
2017-05-14 00:31:45 -07:00
Felipe Leme
bc561eb06e Don't print sensitive data on AssistStructure.dump()
Test: manual verification

Bug: 38205945
Change-Id: Ic184ee6da313a2c0f8e0dd11979f6985d8023140
2017-05-13 18:20:51 -07:00
TreeHugger Robot
5fd8672d71 Merge "Couple autofill fixes." into oc-dev 2017-05-13 03:54:23 +00:00
Felipe Leme
7a1deb7c5f Couple autofill fixes.
- Fixed PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT value - it was overlapping with
PFLAG3_ASSIST_BLOCKED.
- Added missing permission on methods called by Shell command.
- Improved debugging.

Bug: 38173625

Test: android.autofillservice.cts.MultipleFragmentLoginTest#loginOnTwoFragments

Change-Id: Ie7880c97d38298e06134709c5c2e9e38fa1bacbb
2017-05-12 15:34:48 -07:00
Felipe Leme
205d420c68 Fixed and improved (for reuse) PendingRequest lifecycle.
Fixes: 38173625
Test: android.autofillservice.cts.MultipleFragmentLoginTest#loginOnTwoFragments

Change-Id: Ic9ba3cb51048296384d42670cc71db78a0e8fcf6
2017-05-12 15:33:00 -07:00
TreeHugger Robot
a44c50f362 Merge "Do not notifyNoFullUi if no view is focused" into oc-dev 2017-05-12 19:18:02 +00:00
Philip P. Moltmann
20d36c70cd Merge "Safeguard against uncommon scenarios when pruning" into oc-dev 2017-05-12 16:04:02 +00:00
TreeHugger Robot
203ec51e2b Merge "Decrease default number of partitions from 64 to 10." into oc-dev 2017-05-11 22:37:47 +00:00
TreeHugger Robot
208711a1e4 Merge "Ensure remote calls to a fill service timeout." into oc-dev 2017-05-11 20:31:00 +00:00
Philip P. Moltmann
5b4b0fcc0e Do not notifyNoFullUi if no view is focused
Change-Id: I8e2257ee8b9c1885d10ea882af491dd07c8e3e21
Fixes: 38235782
Test: CtsAutoFillServiceTestCases
2017-05-11 12:43:32 -07:00
Philip P. Moltmann
a38666bcec Safeguard against uncommon scenarios when pruning
E.g. more than one session by activity token

Also
- use cheaper datastructure to store sessions temporarily.
- Fix dumping when there are not responses

Fixes: 38203308
Test: Created two sessions, put them in background. Killed the apps, killed the tasks.
      Waited 30 second and started new sessions -> Saw sessions pruned.
Change-Id: I8fe94773a3381617779e5bdded317f3744c831e5
2017-05-11 11:28:48 -07:00
Felipe Leme
6dc0177fe4 Decrease default number of partitions from 64 to 10.
...and also added shell cmds to set it so it can be CTS-tested.

Bug: 37997043

Test: manual verification
Test: PartitionedActivityTest.testNoMorePartitionsAfterLimitReached()
Test: CtsAutoFillServiceTestCases pass

Change-Id: I783bd2d3ed248484adeeebd2df425a6304362ad9
2017-05-11 10:28:20 -07:00
TreeHugger Robot
6ab00addb1 Merge "Speed up structure update before OnFillRequest" into oc-dev 2017-05-11 03:22:22 +00:00
Philip P. Moltmann
22567d3415 Speed up structure update before OnFillRequest
We now
- cache AutofillId -> ViewNode
- look for all AutofillIds at the same time (instead of one by one)

Bug: 37997043
Test: CtsAutoFillServiceTestCases
Change-Id: I094468ad885eed0cc506b4b62ff09c4af48570ff
2017-05-10 17:29:04 -07:00
Felipe Leme
298f89a3e3 Fixed autofill dumpsys and improved logging.
Fixes: 38196286
Bug: 37997043

Test: adb shell dumpsys autofill -a
Test: CtsAutoFillServiceTestCases pass

Change-Id: Ifaae7b5c0894ecf0d16fff8a3c96e4746fe2361b
2017-05-10 12:29:09 -07:00
Svet Ganov
8bf4c8e240 Ensure remote calls to a fill service timeout.
Test: manual

bug:38033547

Change-Id: Ic035b7cd8da0c16fbc80257d6dc3f0c91f0e28b9
2017-05-09 18:51:40 -07:00
Svetoslav Ganov
a9379d0b44 Allow null fill values to support authentication case
If a dataset needs to be authenticated the fill service
may not have the values but needs to tell the system for
which fields to show the fill UI. We now allow passing
a null value to mean the view is a part of the dataset
semantically but its value should remain unchanged.

If a dataset has no values, i.e. the related autofill ids
are mapped to null, we cannot properly filter. In this case
we always match such items regardless what the user typed.

While at this improved accessibility support for filtering
to announce when the number of items being filtered changes.

Also while at this allowed a dataset authentication to return
a response which replaces the current response and refreshes
the UI. Matching datasets with null values to any text plus
allowing a response to be returned from a dataset auth enables
the use case where there is always "Import" item at the
end of the list which when clicked can show arbitrarily more
data entries associated to other apps.

Another change is that we now provide the client state
bundle on both request and dataset auth.

Finally, this change gets rid of dataset waiting auth and
response waiting auth concepts since the reference to the
response and the dataset is piped with the auth request.

Fixed a bug where the width of the autofill UI was not
properly measured by going over all items in the adapter.
Now we measure enough height to fit the first three and the
width id the width of the widest item in the adapter.

Test: Added LoginActivityTest#testDatasetAuthTwoFieldsReplaceResponse
      Added LoginActivityTest#testDatasetAuthTwoFieldsNoValues
      Added LiginActivityTest#filterTextNullValuesAlwaysMatched
      All autofill CTS tests pass

bug:37724701
bug:37424539

Change-Id: Ic19e5d7cbdbb7d110c9e7da0ad60b540cbf1aecf
2017-05-09 17:40:28 -07:00
TreeHugger Robot
f512575c68 Merge changes I7c2c9411,Ibc72c84d,Ib3968644 into oc-dev
* changes:
  No need to deal with windowTokens
  Persistable accessibility ID from ContextWrappers
  Check callbacks when operting on UI
2017-05-09 01:49:58 +00:00
Felipe Leme
370b040cf9 Merge "Fixed placemente of Autofill UI for virtual views." into oc-dev 2017-05-08 21:08:06 +00:00
TreeHugger Robot
85548127a3 Merge "Properly measure dataset presentations" into oc-dev 2017-05-08 21:04:14 +00:00
Philip P. Moltmann
134cee27b8 No need to deal with windowTokens
we have a link to the client which is enough to find the views.

Also there was some cases where the windowToken was not updated
properly. This is moot now.

Also: Read a array of views from the client to speed up the
client<->AutofillManager communication.

Fixes: 38070352
Test: CtsAutoFillServiceTestCases
      1 Started autofill, saw fill UI
      2 Home button
      3 Kill activity in background
      4 Recents -> back to activity
      5 Saw fill UI restored
Change-Id: I7c2c9411204fa5d65867efae9b7296399121c3a2
2017-05-08 14:02:58 -07:00
Philip P. Moltmann
33948042ff Check callbacks when operting on UI
This makes sure that only the session that current owns the UI can make
changes to the UI:

The callback is the ID of the current owner. The only caller that does
not ID itself (and thereby causes the Ui to close in any way) is the
ACTION_CLOSE_SYSTEM_DIALOGS path.

Change-Id: Ib396864411f362b59deb500251c37896ecbc7de7
Fixes: 38042845
Test: CtsAutoFillServicesTestCases
2017-05-08 13:29:08 -07:00
TreeHugger Robot
1c38d29482 Merge "Fixed scenario where an authentication response has no dataset." into oc-dev 2017-05-08 19:20:16 +00:00
Svetoslav Ganov
2e3b0c11c3 Properly measure dataset presentations
Test: Autofill CTS tests pass

bug:37952199

Change-Id: Iaae714dd483ba44d5c7668b6fc7d386901b9d95c
2017-05-08 18:58:51 +00:00
TreeHugger Robot
6bfcc82a4b Merge "Only clear state for force stopped fill service" into oc-dev 2017-05-07 01:17:08 +00:00
Svet Ganov
f37ba7496f Only clear state for force stopped fill service
Test: manual

bug:37785814

Change-Id: I5e40a284788bacf1ebae5ddefffb93b1a5b47d39
2017-05-06 16:12:20 -07:00
Felipe Leme
8fd0575327 Fixed scenario where an authentication response has no dataset.
Also use getUiForShowing() on all relevant places, and added missing
SaveDataType value.

Test: LoginActivityTest.testFillResponseAuthServiceHasNoData()
Test: manual verification

Fixes: 37711385
Fixes: 38009452

Change-Id: Id69c831f96fb9ac35d1f2d86cfd41e76428c776e
2017-05-05 17:17:07 -07:00