Commit Graph

33 Commits

Author SHA1 Message Date
Felipe Leme
326f15a392 Optimized Content Capture workflow by caching some state at the application level.
Content Capture for an activity and/or package is only available when the Content Capture service
explicitly whitelists it. As the whitelist is kept at system-server level, it's better to fetch that
info when the application is started and cache it locally, so we can optimize the
ContentCaptureManager APIs to return quickly when it's disabled.

This CL also caches other values such as the buffer parameters.

Test: atest CtsContentCaptureServiceTestCases

Bug: 120494182
Bug: 121202151

Change-Id: I9d5211bca496ffa85ba9efc2a7bb32411834b787
2019-02-20 18:44:05 -08:00
Felipe Leme
72e83d8c3d Changed ContentCaptureManager API so service can only disable itself.
To re-enable, it will need to launch a Settings intent
(Settings.ACTION_REQUEST_ENABLE_CONTENT_CAPTURE).

Bug: 123286662
Test: atest CtsContentCaptureServiceTestCases

Change-Id: I0dd03013aba645c188af4034e530492d8294180e
2019-02-19 09:29:14 -08:00
Felipe Leme
e8eae9d420 Initial implementation of ContentCaptureService.setContentCaptureWhitelist()
For now it only whitelists packages, not activities.

Test: atest CtsContentCaptureServiceTestCases

Bug: 122595322

Change-Id: I5beb9b027eb704510e68f3af15e84e14bda07eb2
2019-02-15 20:00:49 -08:00
Felipe Leme
d32d8f6f3c Added DeviceConfig properties to fine tune ContentCapture:
- DEVICE_CONFIG_PROPERTY_MAX_BUFFER_SIZE
- DEVICE_CONFIG_PROPERTY_IDLE_FLUSH_FREQUENCY
- DEVICE_CONFIG_PROPERTY_TEXT_CHANGE_FLUSH_FREQUENCY
- DEVICE_CONFIG_PROPERTY_LOG_HISTORY_SIZE
- DEVICE_CONFIG_PROPERTY_LOGGING_LEVEL

Test: manual verification
Test: atest CtsContentCaptureServiceTestCases

Bug: 123096662
Fixes: 121044064
Fixes: 121044306

Change-Id: I08623516bb7ebbe9c900987be853f4f395250016
2019-02-15 17:32:04 -08:00
Felipe Leme
4eecbe6e3c Add new ContentCapture APIs to let apps change the ContentCaptureContext.
Test: atest CtsContentCaptureServiceTestCases:android.contentcaptureservice.cts.LoginActivityTest#testSimpleLifecycle_changeContextOnCreate \
   CtsContentCaptureServiceTestCases:android.contentcaptureservice.cts.LoginActivityTest#testSimpleLifecycle_changeContextAfterCreate
Test: atest FrameworksCoreTests:android.view.contentcapture.ContentCaptureEventTest

Bug: 124266664

Change-Id: I0348e81e1b2bac01363cf615d2ab32e5bab8aee1
2019-02-12 11:31:06 -08:00
Felipe Leme
5fd6011770 Merge "Added DISALLOW_CONTENT_CAPTURE to UserRestrictionsUtils." 2019-02-11 20:08:08 +00:00
Felipe Leme
08c920219e Added DISALLOW_CONTENT_CAPTURE to UserRestrictionsUtils.
Also fixed FrameworkResourcesServiceNameResolver.isDefaultServiceEnabled()

Test: atest MixedManagedProfileOwnerTest#testDisallowContentCapture_allowed \
            MixedManagedProfileOwnerTest#testSetUserRestrictionLogged \
            MixedDeviceOwnerTest#testDisallowContentCapture_allowed \
            MixedDeviceOwnerTest#testSetUserRestrictionLogged \
            MixedProfileOwnerTest#testDisallowContentCapture_allowed \
            MixedProfileOwnerTest#testSetUserRestrictionLogged \
Bug: 123406031

Change-Id: If80257a1023229adcb19f41c90deb2de07ab6c7c
2019-02-08 14:54:53 -08:00
Felipe Leme
14ef461fc2 Reverted ContentCapture kill-switch mechanism.
Fixes: 121153631
Fixes: 121144410

Test: atest CtsContentCaptureServiceTestCases

Change-Id: Ic0e3fe6e93a8c2aff12eebcf9872f0082a361589
2019-02-08 10:45:50 -08:00
Felipe Leme
5e1e709992 Disable ContentCapture at runtime when it's disabled by DeviceConfig.
Prior to this change, it would only be disabled on boot.

Test: atest ChildlessActivityTest#testSetContentCaptureFeatureEnabled_disabledByDeviceConfig \
      ChildlessActivityTest#testSetContentCaptureFeatureEnabled_disabledThenReEnabledByDeviceConfig
Test: atest CtsContentCaptureServiceTestCases

Bug: 123931489

Change-Id: I9230574db3ee85ba95951a3d9329c96f4e84a87e
2019-02-07 21:04:18 -08:00
Felipe Leme
567df6a429 Add shell cmd to disabled default Content Capture service.
Otherwise a bunch of CTS tests fail when the OEM sets a default service.

Test: atest CtsContentCaptureServiceTestCases
Fixes: 123952975

Change-Id: Ia172fbde6670fc5f125425f9dc92a34e8cdfdaed
2019-02-05 15:09:16 -08:00
TreeHugger Robot
1a9862c9da Merge "Removed the Content Capture blacklist APIs." 2019-02-04 23:04:48 +00:00
Felipe Leme
3186bcdeda Removed the Content Capture blacklist APIs.
We'll initially implement just the whitelist ones...

Bug: 122595322

Test: m update-api
Test: atest CtsContentCaptureServiceTestCases

Change-Id: I403716905d429abb2e1cb4085c838706226e9969
2019-01-31 18:08:20 -08:00
Adam He
bb82c6a9f0 Implement getting displayId from ActivityManager
Change-Id: Ib8659062e5dd58b49c1e1fdee03f5f6a65e00971
Fixes: 121260224
Test: atest CtsContentCaptureServiceTestCases
2019-01-31 15:33:36 -08:00
Felipe Leme
bb0c2a2a33 Added new APIs to let ContentCaptureService enable / disable the feature.
Bug: 123286662
Test: atest ChildlessActivityTest#testSetContentCaptureFeatureEnabled_disabledByApi \
        ChildlessActivityTest#testSetContentCaptureFeatureEnabled_disabledThenReEnabledByApi
Test: atest CtsContentCaptureServiceTestCases # for sanity check

Change-Id: Ideefb4c8e122e5f3f55dd7de8085212b2d8ce073
2019-01-28 16:20:39 -08:00
Felipe Leme
91ddecac0a Added new APIs to let Settings enable / disable ContentCapture
Bug: 123286662
Test: atest ChildlessActivityTest#testSetContentCaptureFeatureEnabled_disabledBySettings \
        ChildlessActivityTest#testSetContentCaptureFeatureEnabled_disabledThenReEnabledBySettings\
        FrameworksCoreTests:SettingsBackupTest#secureSettingsBackedUpOrBlacklisted
Test: atest CtsContentCaptureServiceTestCases # for sanity check

Change-Id: I7cd2c36c1d7e23efb9acacf4f18cecd8838f5ac5
2019-01-28 16:20:30 -08:00
Felipe Leme
f2aa0d2214 Removed userId from ContentCapture binder calls.
It should be infered on the server side..

Bug: 123516968

Test: atest CtsContentCaptureServiceTestCases

Change-Id: If6ccf2fa86adb55f43c4b3ffa8b58661ef16dabb
2019-01-28 11:33:12 -08:00
Adam He
3d0409b00f Implement onUserDataRemovalRequest
Change-Id: I7c818d42000b6155f9dcaad85b7f9f761741a484
Fixes: 121289354
Test: atest CtsContentCaptureServiceTestCases # still passing
Test: manual verification
2019-01-22 12:02:48 -08:00
TreeHugger Robot
db11760580 Merge "Log Content Capture and Augmented Autofill requests." 2019-01-17 20:01:46 +00:00
TreeHugger Robot
a8b50584c6 Merge "Added IContentCaptureServiceCallback." 2019-01-16 16:30:57 +00:00
Felipe Leme
930f324b10 Log Content Capture and Augmented Autofill requests.
Test: manual verification
Bug: 111276913
Bug: 111330312

Change-Id: I84c23a60ed83d429b72600145e3c3877835ebe78
2019-01-15 17:17:09 -08:00
Felipe Leme
01b8749b40 Improved ContentCaptureManagerSession state.
Test: atest CtsContentCaptureServiceTestCases
Bug: 111276913

Change-Id: I8b1f36174582d89913d5d170abb65789a16818ec
2019-01-15 14:52:35 -08:00
Felipe Leme
af4e4fd020 Added IContentCaptureServiceCallback.
This binder object will be used to implement the ContentCaptureService methods that require calls to
system server.

Bug: 122595322
Test: atest CtsContentCaptureServiceTestCases

Change-Id: If918af540f78777d00970e0fc75df458aad168b7
2019-01-15 09:26:43 -08:00
Perumaal S
addabbaf82 Implement getServiceComponentName API for Content Capture
Tests are in ag/5989968

Fixes: 121047489
Test: atest CtsContentCaptureServiceTestCases # to make sure nothing broke
Test: atest
CtsContentCaptureServiceTestCases:android.contentcaptureservice.cts.BlankActivityTest#testTargetServiceName_enabled
Test: google3 test with test app
Change-Id: I4f11a324beb938a28cd150c35bb3d83c77e59e0b
2019-01-10 12:32:12 -08:00
Felipe Leme
e127c9a47e Fixed how session created / removed events are generated.
Long-story short, they must be flushed right away...

Test: atest CtsContentCaptureServiceTestCases
Bug: 121033016

Change-Id: I1b3132ad49674d43bf63717f79848b6e4b23b605
2019-01-04 17:54:52 -08:00
Felipe Leme
bb98ed6521 New APIs for ContentCaptureService: onConnected() and onDisconnected()
Bug: 117944706
Test: atest CtsContentCaptureServiceTestCases:android.contentcaptureservice.cts.BlankActivityTest#testDisconnected
Test: atest CtsContentCaptureServiceTestCases

Change-Id: Iba3c1ae774221946a550fad95539d3a9771ae3d7
2018-12-21 15:11:49 -08:00
Felipe Leme
50b33dce59 Refactored ContentCaptureService (and infra) to have just one RemoteService.
The initial implementation of AbstractPerUserService assumed the
AbstractRemoteService instances would be created in demand, because that was
the aproach used by Autofill (to minimize the time system service is bound to
the autofill service process).

But for other systems like ContentCapture, it makes more sense to keep a
permanent connection to the remote service, which is running all the time, so
this change changes the infra to allow such permanent connection (which includes
defining an idle timeout value that never unbinds).

Bug: 117779333
Test: atest CtsContentCaptureServiceTestCases CtsAutoFillServiceTestCases

Change-Id: I43386a3fddc56f1dfd6e4e55f243eaa297921123
2018-12-21 13:25:07 -08:00
Felipe Leme
c28711c5f0 Refactored ServiceNameResolver to take userId.
This object is used to bind to the AbstractRemoteInstance and was initially used by
AbstractPerUserSystemService, as the concrete implementations (for Autofill and ContentCapture)
were binding when sessions were created.

But we also need to support binding when the service is created, which was not possible using this
approach; instead, we need to make this object to take the userId on each call, and move it to the
AbstractMasterSystemService.

This change also removed the shared lock from FrameworkResourcesServiceNameResolver.

Bug: 117779333
Test: atest CtsContentCaptureServiceTestCases CtsAutoFillServiceTestCases

Change-Id: I097c226c9b00ddf7827e4f2f99d0adba978f29a2
2018-12-21 13:25:07 -08:00
Felipe Leme
87a9dc9a97 Moved createContentCaptureSession() to ContentCaptureSession.
Such move will allow nested sessions. For example, WebView could create a
new session for the main page, then child sessions for IFRAMEs contained on it.

This CL changes the API and provides an initial implementation, although it's
not quite ready yet - it only allows 1 level of children (from the activity
session), but the full implementation is coming soom to a movie theather near
you...

Bug: 121033016
Bug: 117944706

Test: atest CtsContentCaptureServiceTestCases

Change-Id: I86156bb3b8a2c08cb00b9518599eb6d67fbf77c2
2018-12-20 08:59:48 -08:00
Philip P. Moltmann
29ee0a4827 Make AbstractRemoteService available outside of system server
The handler of the services now runs on Looper.getMainLooper()

Test: Built
Bug: 117779333
Change-Id: Ie2fee4ce19d6e6181537d8adc196a4ceab7eb0f8
2018-12-19 13:39:13 -08:00
Felipe Leme
b9687849bb Optimizes the Content Capture workflow by calling the service directly.
Initially, the ContentCaptureManager (in the app) was calling the
IContentCaptureManager (on system server) for everything, even to pass the
list of captured events, which caused 2 IPCs for each batch of events (i.e.,
from app to system_server, then from system_service to service).

This CL optimizes the workflow by getting rid of the "middle man" and sending
the events from the app to the service directly, which the system_server only
calling the service to notify when the view starts and finishes (and passing
the UID in the former so the servier can validate the sendEvents() calls).

Bug: 119220549
Test: atest CtsContentCaptureServiceTestCases

Change-Id: I6c08dccf755605320ac37cbc9424132e5455a594
2018-12-18 10:03:37 -08:00
Felipe Leme
aa5088ede6 Another round of changes on Content Capture.
- Get rid of activity-level events.
- Renamed InteractionSessionId and InteractionContext to
  ContentCaptureSessionId and ContentCaptureContext (and made them public)
- Create the explicit concept of ContentCaptureSesssion (and moved notification
  APIs to it).
- Added APIs to let apps create new sessions (not implemented yet).
- Added APIs to remove user data based on some context properties (like URI).

The reasoning behind this change is to let app developers explicitly associate
the captured content with some app-level domain (and also let the app ask the
service to clear such data at user's request). For example, a browser app
(and WebView) can use these APIs to associate the content capture events with
the URL being rendered.

Bug: 117944706
Fixes: 121034139

Test: atest CtsContentCaptureServiceTestCases
Test: m update-api && m

Change-Id: I7841da303b6a39c825651b03a07e3081fbd0bdf5
2018-12-14 18:02:24 -08:00
Felipe Leme
afb55b6813 Simplified how AbstractRemoteService subclasses run an async request.
In these cases the request never times out, so it can be simplified by using
a lambda to represent the request.

Bug: 117779333
Test: atest CtsContentCaptureServiceTestCases CtsAutoFillServiceTestCases

Change-Id: Iba52aad1315ae7d3982671a0fdeabe87a6d6ee04
2018-12-06 20:31:24 -08:00
Felipe Leme
749b889889 Yet another (major) refactoring on Content Capture and Augmented Autofill.
Bunch of changes:

- Split public SmartSuggestionsService info ContentCaptureService and
  AugmentedAutofillService
- Renamed 'intelligence' packages to either 'contentcapture' or
  'autofil.augmented'
- Renamed internal packages and classes.
- Changed permissions, resource names, etc...
- Moved Augmented Autofill logic from IntelligeceManagerService (R.I.P.) to
  Autofill.
- Optimized IPCs by passing a String instead of the InteractionSessionId
  (that also solves the view -> service dependency).

Test: atest CtsContentCaptureServiceTestCases \
            CtsAutoFillServiceTestCases \
            FrameworksCoreTests:SettingsBackupTest
Test: manual verification with Augmented Autofill Service

Bug: 119638877
Bug: 117944706

Change-Id: I787fc2a0dbd9ad53e4d5edb0d2a9242346e4652d
2018-12-06 16:56:39 -08:00