Commit Graph

51 Commits

Author SHA1 Message Date
Felipe Leme
518fb624c0 Changed ContentCapture session lifecycle so session is kept alive when service died.
This is useful for long-lived activities (like a browser), so child session can still be reported
after the service is restarted after dying.

Test: manual verification (cannot be tested using CTS because it would kill the test process)
Test: atest FrameworksCoreTests:android.view.contentcapture.ContentCaptureEventTest
Test: m update-api

Bug: 128466656

Change-Id: I9310263e897e929189d323d31853592a374dc6e0
2019-03-13 16:10:05 -07:00
TreeHugger Robot
d1bd765392 Merge "Add RoleControllerManager for role controller service." 2019-03-08 21:32:00 +00:00
Stanislav Zholnin
0b69c75a7c Merge "Use updated DeviceConfig API's new getters to simplify invocations." 2019-03-08 10:19:06 +00:00
Hai Zhang
a4959e569d Add RoleControllerManager for role controller service.
This allows us to expose both system-only and app available APIs for
role in RoleControllerService.

Bug: 127691087
Test: manual
Change-Id: I86fe3736fc28516aae25d48efe3ba599ffdf45d5
2019-03-07 21:33:12 -08:00
Felipe Leme
0879ad0bd4 Merge "Don't destroy service when the bind connection died." 2019-03-08 03:44:51 +00:00
TreeHugger Robot
06ff48f856 Merge "New API: ContentCaptureService.onActivityEvent()" 2019-03-07 23:35:34 +00:00
Felipe Leme
817b5e12f9 Don't destroy service when the bind connection died.
Otherwise it won't reconnect...

Bug: 126807984
Test: manual verification

Change-Id: I54c7fc244672d38f387f786ea13a7ffb54aca44b
2019-03-07 14:46:59 -08:00
Felipe Leme
141864d610 New API: ContentCaptureService.onActivityEvent()
This API is needed for high-level events that happened on activities that are
not whitelisted for Content Capture.

Test: atest CtsContentCaptureServiceTestCases:android.contentcaptureservice.cts.LoginActivityTest#testSimpleLifecycle_defaultSession
Test: atest CtsContentCaptureServiceTestCases # sanity check
Test: m update-api

Bug: 126262658

Change-Id: Id2d4ccfb04d56eba561200d6875374a932c526ae
2019-03-07 13:06:21 -08:00
TreeHugger Robot
69ea91828c Merge "Improved how content capture is disabled by settings." 2019-03-07 18:44:31 +00:00
Stanislav Zholnin
a534368e75 Use updated DeviceConfig API's new getters to simplify invocations.
Test: manual verification
Change-Id: I213f25c9b16d7988617bcf127461a9097a8e16b3
2019-03-07 16:49:37 +00:00
Felipe Leme
8db0036c21 Improved how content capture is disabled by settings.
- Use 1/0 instead of true/false for the settings value.
- Improved logging / internal logic by splitting disabled by settings and device config.
- Other minor fixes.

Test: atest CtsContentCaptureServiceTestCases

Bug: 119264902

Change-Id: I51b99588f823c4e1eaf496841efd45757e4258be
2019-03-06 17:59:02 -08:00
Felipe Leme
0f0b1d383d Fixed Content Capture and Augmented Autofill whitelist.
Bug: 125348180
Test: atest CtsContentCaptureServiceTestCases AugmentedLoginActivityTest

Change-Id: Ia7a9b1ebbd14c0011a4806bcf5ba87f438510129
2019-03-06 12:08:39 -08:00
Adam He
70ebc5a508 Check for empty arguments in setWhitelist().
Bug: 125348180
Test: atest CtsContentCaptureServiceTestCases
Test: atest FrameworksCoreTests:com.android.internal.infra.WhitelistHelperTest
Change-Id: I9c2296ebe2762e97f03350b365b148429b15ab60
2019-03-05 14:51:30 -08:00
Adam He
6240eab185 Implemented a WhitelistHelper for whitelisting packages/activities for Augmented Autofill and Content Capture.
Fixes: 125348180
Test: atest android.contentcaptureservice.cts.LoginActivityTest
Test: atest android.autofillservice.cts.augmented.AugmentedLoginActivityTest
Test: atest FrameworksCoreTests:com.android.internal.infra.WhitelistHelperTest
Change-Id: I59c32d5a05c9c1ee813395545507fc8eaee47745
2019-03-04 16:15:32 -08:00
Felipe Leme
a820910468 Added DeviceConfig properties for Augmented Autofill service timeouts.
Test: manual verification
Bug: 123100811

Change-Id: I82749b4cea5fe90998efa0798fb6b032a8470086
2019-02-25 16:20:18 -08:00
TreeHugger Robot
5daa6d5c67 Merge "Added a DeviceConfig property for Content Capture idle timeout to unbind from system server." 2019-02-25 21:10:50 +00:00
Felipe Leme
e764fa2892 Added a DeviceConfig property for Content Capture idle timeout to unbind from system server.
Test: manual verification
Bug: 111276913

Change-Id: I3c8f0ffc5fbadfc033ef6574cab7e0ec1419b38e
2019-02-25 09:42:14 -08:00
Felipe Leme
81299d0d96 Made AbstractRemoteService.getRemoteRequestMillis() optional.
Also split some logic from PendingRequest into BasePendingRequest, so they're
not leaked into the async requests.

Test: atest CtsContentCaptureServiceTestCases CtsAutoFillServiceTestCases
Bug: 117779333
Change-Id: Ife9a3ab3a817944408caf9eae69dd75f48ab90c6
2019-02-21 16:11:26 -08:00
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